summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 25d3b78)
raw | patch | inline | side by side (parent: 25d3b78)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 25 Aug 2010 09:45:24 +0000 (09:45 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 25 Aug 2010 09:45:24 +0000 (09:45 +0000) |
-Added object count to statistics transmit function
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19449 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19449 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_stats.inc | patch | blob | history | |
gosa-core/plugins/generic/statistics/class_statistics.inc | patch | blob | history |
index 1523d6d64bc05842710d56e18a0adb60c7b0fb5a..6ea22bffcb9fe15a87af23e7c66252548437a613 100644 (file)
* @param int to The timestamp to end the request.
* @return array An array containing the requested entries.
*/
- static function dumpTables($filename)
+ static function generateStatisticDump($filename)
{
// Get database connection
$TABLE_NAME = stats::$tableName;
rename($path.'/'.$filename, $path.'/'.$filename.".old");
}
}
+
+
+ static function getLdapObjectCount($config, $statisticConformResult = FALSE)
+ {
+ $ldap = $config->get_ldap_link();
+ $ldap->cd($config->current['BASE']);
+
+ // A list of objectClasses to search for, indexed by their
+ // object-category
+ $ocsToSearchFor = array(
+ "department" => array("gosaDepartment"),
+ "devices" => array("gotoDevice"),
+ "fai" => array("FAIobject"),
+ "gofaxlist" => array("goFaxRBlock","goFaxSBlock"),
+ "gofonconference" => array("goFonConference"),
+ "phone" => array("goFonHardware"),
+ "gofonmacro" => array("goFonMacro"),
+ "users" => array("gosaAccount"),
+ "acls" => array("gosaAcl","gosaRole"),
+ "application" => array("gosaApplication"),
+ "ogroups" => array("gosaGroupOfNames"),
+ "roles" => array("organizationalRole"),
+ "server" => array("goServer"),
+ "printer" => array("gotoPrinter"),
+ "terminal" => array("gotoTerminal"),
+ "workstation" => array("gotoWorkstation"),
+ "winworkstation" => array("sambaSamAccount"),
+ "incoming" => array("goHard"),
+ "component" => array("ieee802Device"),
+ "mimetypes" => array("gotoMimeType"),
+ "groups" => array("posixGroup"),
+ "sudo" => array("sudoRole"));
+
+ // Build up a filter which contains all objectClass combined by OR.
+ // We will later sum up the results using PHP.
+ $filter = "";
+ $categoryCounter = array();
+ foreach($ocsToSearchFor as $category => $ocs){
+ foreach($ocs as $oc){
+ $filter.= "(objectClass={$oc})";
+ }
+ $categoryCounter[$category] = 0;
+ }
+ $filter = "(|{$filter})";
+
+ // Initiate the ldap query
+ $res = $ldap->search($filter, array('objectClass'));
+ if($ldap->success()) {
+
+ // Count number of results per category
+ while($entry = $ldap->fetch()){
+ foreach($ocsToSearchFor as $category => $ocs){
+ if(count(array_intersect($ocs, $entry['objectClass']))){
+ $categoryCounter[$category] ++;
+ break;
+ }
+ }
+ }
+ }
+ arsort($categoryCounter);
+
+ // Do we have to return the result as SQL INSERT statement?
+ if($statisticConformResult){
+ $uuid = $config->getGOsaUUID();
+ $type = 'objectCount';
+ $plugin = '';
+ $action = '';
+ $date = date('Y-m-d');
+ $memory_usage = sqlite_escape_string(stats::get_memory_usage());
+ $cpu_load = sqlite_escape_string(number_format(stats::get_cpu_load(),4,'.',''));
+ $sql = array();
+ foreach($categoryCounter as $category => $amount){
+ $sql[] = array($type, $plugin, $category,$action,$uuid,$date, 0,0,$amount,$memory_usage,$cpu_load,'');
+ }
+ return($sql);
+ }else{
+ return($categoryCounter);
+ }
+ }
}
?>
diff --git a/gosa-core/plugins/generic/statistics/class_statistics.inc b/gosa-core/plugins/generic/statistics/class_statistics.inc
index 94eebdc5fc2178972813eceedd6eeb70090e40ef..b7285e4577a5715ffe986bd10f81bb2c03630080 100644 (file)
var $graph1DatePicker1 = 0;
var $graph1DatePicker2 = 0;
- // A collection opf timestamps for unsubmitted statistics data.
+ // A collection of timestamps for unsubmitted statistics data.
var $unsbmittedFiles = array();
var $graphs = array();
$this->staticChart2 = new pieChart2($config);
// Init start and stop times for graph 1
- $this->graph1DatePicker1 = date('d.m.Y', time() - 14 * 24 * 60 *60);
+ $this->graph1DatePicker1 = date('d.m.Y', time() - 28 * 24 * 60 *60);
$this->graph1DatePicker2 = date('d.m.Y', time());
// First try to retrieve values via RPC
$smarty->assign('graph1DatePicker1', $this->graph1DatePicker1);
$smarty->assign('graph1DatePicker2', $this->graph1DatePicker2);
- // Assign list of graphs
- $tmp = array();
- foreach($this->graphs as $id => $gClass){
- $tmp[$id] = $gClass->getTitle();
- }
- $smarty->assign("selectedGraphType", $this->selectedGraphType);
- $smarty->assign("availableGraphs", $tmp);
-
-
// Do not render anything if we are not prepared to send and receive data via rpc.
$smarty->assign("rpcConfigured", $this->rpcConfigured);
$smarty->assign("validRpcHandle", TRUE);
return($smarty->fetch(get_template_path('statistics.tpl', TRUE)));
}
+ // Assign list of selectable graphs
+ $tmp = array();
+ foreach($this->graphs as $id => $gClass){
+ $tmp[$id] = $gClass->getTitle();
+ }
+ $smarty->assign("selectedGraphType", $this->selectedGraphType);
+ $smarty->assign("availableGraphs", $tmp);
+
// Send stats
if(isset($_POST['transmitStatistics'])){
$this->unsbmittedFiles = $this->getUnsubmittedStatistics();
foreach($this->unsbmittedFiles as $filename => $date){
- $tmp = stats::dumpTables($filename);
+ $tmp = stats::generateStatisticDump($filename);
$dump = array();
foreach($tmp as $entry){
$dump[] = array_values($entry);
}
+ $objectCount = stats::getLdapObjectCount($this->config, TRUE);
+ $dump = array_merge($dump, $objectCount);
$res = $this->rpcHandle->updateInstanceStatus($dump);
if(!$this->rpcHandle->success()){
msg_dialog::display(_("Error"),msgPool::rpcError($this->rpcHandle->get_error()),ERROR_DIALOG);
}
// Transmit daily statistics to GOsa-Server
- if(isset($_POST['receiveStatistics']) && $this->rpcConfigured){
+ if((isset($_POST['receiveStatistics']) || !count($this->statisticData)) && $this->rpcConfigured){
$start = strtotime($this->graph1DatePicker1);
$stop = strtotime($this->graph1DatePicker2);
$res = $this->rpcHandle->getInstanceStats($start,$stop);
}
$this->rpcHandle_Error = !$this->rpcHandle->success();
}
-
+
+ // Update graphs
$this->reloadGraphs();
$smarty->assign('staticChart1_ID', $this->staticChart1->getGraphID());