From: hickert Date: Tue, 7 Sep 2010 05:51:34 +0000 (+0000) Subject: Updated statistic file generation X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7f81940983d9866ab0c8583e5d27b15926de2d4d;p=gosa.git Updated statistic file generation -Dates were messed up, when reports were not send the same day they were created git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19535 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_stats.inc b/gosa-core/include/class_stats.inc index 6ea22bffc..ae5be145d 100644 --- a/gosa-core/include/class_stats.inc +++ b/gosa-core/include/class_stats.inc @@ -334,7 +334,7 @@ class stats } - static function getLdapObjectCount($config, $statisticConformResult = FALSE) + static function getLdapObjectCount($config, $statisticConformResult = FALSE, $date = "") { $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); @@ -399,12 +399,24 @@ class stats $type = 'objectCount'; $plugin = ''; $action = ''; - $date = date('Y-m-d'); + $date = (empty($date))?date('Y-m-d'):$date; $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,''); + $sql[] = array( + "type" => $type, + "plugin" => $plugin, + "category" => $category, + "action" => $action, + "uuid" => $uuid, + "date" => $date, + "duration" => 0, + "render_time" => 0, + "amount" => $amount, + "mem_usage" => $memory_usage, + "load" => $cpu_load, + "info" => ''); } return($sql); }else{ diff --git a/gosa-core/plugins/generic/statistics/class_statistics.inc b/gosa-core/plugins/generic/statistics/class_statistics.inc index 591345885..852c7ec6f 100644 --- a/gosa-core/plugins/generic/statistics/class_statistics.inc +++ b/gosa-core/plugins/generic/statistics/class_statistics.inc @@ -158,13 +158,39 @@ class statistics extends plugin if(isset($_POST['transmitStatistics'])){ $this->unsbmittedFiles = $this->getUnsubmittedStatistics(); foreach($this->unsbmittedFiles as $filename => $date){ + + $strDate = date('Y-m-d', $date); $tmp = stats::generateStatisticDump($filename); $dump = array(); + $invalidDateCount = 0; foreach($tmp as $entry){ + + // Check if the result date equals the report file date + // - If not update the entry. + if($entry['date'] != $strDate){ + $entry['date'] = $strDate; + $invalidDateCount ++; + } + $dump[] = array_values($entry); + } + + // Merge result with ldap object count + $objectCount = stats::getLdapObjectCount($this->config, TRUE, date('Y-m-d', $date)); + foreach($objectCount as $entry){ + + // Check if the result date equals the report file date + // - If not update the entry. + if($entry['date'] != $strDate){ + $entry['date'] = $strDate; + $invalidDateCount ++; + } $dump[] = array_values($entry); } - $objectCount = stats::getLdapObjectCount($this->config, TRUE); - $dump = array_merge($dump, $objectCount); + + // Warn about invalid dates transmitted + if($invalidDateCount) trigger_error(sprintf("Report contained %s entries with invalid date string!",$invalidDateCount)); + + // Send in our report now. $res = $this->rpcHandle->updateInstanceStatus($dump); if(!$this->rpcHandle->success()){ msg_dialog::display(_("Error"),msgPool::rpcError($this->rpcHandle->get_error()),ERROR_DIALOG);