From bece27b1bbe9310f2b2436337879ac75b5f9e7e8 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 2 Aug 2010 15:05:47 +0000 Subject: [PATCH] Updated sqlite handling git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19344 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_stats.inc | 41 +++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/gosa-core/include/class_stats.inc b/gosa-core/include/class_stats.inc index 9d6517c3d..c8631ce2e 100644 --- a/gosa-core/include/class_stats.inc +++ b/gosa-core/include/class_stats.inc @@ -70,6 +70,8 @@ class stats $TABLE_NAME = stats::$tableName; $query = "DROP TABLE '{$TABLE_NAME}'"; $ret = sqlite_query($query, $handle); + stats::$lastHandle = NULL; + stats::getDatabaseHandle(); } @@ -147,6 +149,7 @@ class stats // Get database handle, if it is invalid (NULL) return without creating stats $res = stats::getDatabaseHandle(); +# stats::dropTable($res); if(!$res) return; // Ensure that 'clicks' and 'overallRenderTimer' are present and set correctly, @@ -154,7 +157,7 @@ class stats // -- 'clicks' is a counter wich is set in main.php -> Number of page reloads // -- 'overallRenderTimer' is set in main.php -> timestamp of rendering start. if(!isset($clicks) || empty($clicks)) $clicks = 0; - if(!isset($overallRenderTimer) || empty($overallRenderTimer)){ + if(!isset($overallRenderTimer)){ $renderTime = 0; }else{ $renderTime = microtime(TRUE) - $overallRenderTimer; @@ -164,6 +167,16 @@ class stats $overallRenderTimer = microtime(TRUE); } + // Enforce floating point values ...damn this sucks. + $duration += 0.000001; + $renderTime += 0.000001; + + $duration = sprintf("%0.6f",$duration); + $renderTime = sprintf("%0.6f",$renderTime); + + $duration = preg_replace("/\./",",",$duration); + $renderTime = preg_replace("/\./",",",$renderTime); + // Prepare values to be useable within a database $uuid = $config->getGOsaUUID(); $type = sqlite_escape_string($type); @@ -177,7 +190,7 @@ class stats $info = sqlite_escape_string($info); $clicks = sqlite_escape_string($clicks); $memory_usage = sqlite_escape_string(stats::get_memory_usage()); - $cpu_load = sqlite_escape_string(stats::get_cpu_load()); + $cpu_load = sqlite_escape_string(sprintf("%0.6f",stats::get_cpu_load())); // Clean up category, which usally comes from acl_category and may still contain // some special chars like / @@ -208,6 +221,7 @@ class stats static function show() { $res = stats::getDatabaseHandle(); +# stats::dropTable($res); if(!$res) return; $TABLE_NAME = stats::$tableName; @@ -543,6 +557,29 @@ class stats } echo sqlite_error_string($ret); + + echo "\n------ \n"; + echo "Rendertime per plugin\n"; + echo "------ \n"; + + $query = " + SELECT PLUGIN, RENDER_TIME * 1000000 AS RM + FROM {$TABLE_NAME} + GROUP BY PLUGIN + "; + $ret = sqlite_query($query, $res); + + $colSize = 16; + $title = FALSE; + foreach(sqlite_fetch_all($ret) as $entry){ + foreach($entry as $key => $str){ + if(is_numeric($key)) continue; + echo str_pad($str,$colSize,' ')."|"; + } + echo "\n"; + } + echo sqlite_error_string($ret); + echo ""; } } -- 2.30.2