From fe52ec494fc661c56dfde820bb46752bde0061ad Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 2 Aug 2010 11:11:29 +0000 Subject: [PATCH] Added some more queries for the stats db git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19339 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_stats.inc | 114 +++++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 1 deletion(-) diff --git a/gosa-core/include/class_stats.inc b/gosa-core/include/class_stats.inc index 06cf3f85a..a043c4dc0 100644 --- a/gosa-core/include/class_stats.inc +++ b/gosa-core/include/class_stats.inc @@ -329,8 +329,120 @@ class stats } echo "\n"; } - echo ""; echo sqlite_error_string($ret); + + echo "\n------ \n"; + echo "Time per session\n"; + echo "------ \n"; + + $query = " + SELECT SUM(DURATION) as DUR, UUID + FROM {$TABLE_NAME} + GROUP BY UUID + ORDER BY DUR DESC LIMIT 10"; + $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 "\n------ \n"; + echo "Most used password hashes\n"; + echo "------ \n"; + + $query = " + SELECT DISTINCT(INFO), COUNT(INFO) as CNT + FROM {$TABLE_NAME} + WHERE ACTION = 'change_password' + GROUP BY INFO + ORDER BY INFO DESC LIMIT 10"; + $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 "\n------ \n"; + echo "Actions at all\n"; + echo "------ \n"; + + $query = " + SELECT DISTINCT(ACTION), COUNT(ACTION) AS CNT + FROM {$TABLE_NAME} + GROUP BY ACTION + ORDER BY CNT DESC LIMIT 10"; + $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 "\n------ \n"; + echo "Time spent per action\n"; + echo "------ \n"; + + $query = " + SELECT DISTINCT(ACTION), SUM(DURATION) AS DUR + FROM {$TABLE_NAME} + GROUP BY ACTION + ORDER BY DUR DESC LIMIT 10"; + $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 "\n------ \n"; + echo "Average time per action\n"; + echo "------ \n"; + + $query = " + SELECT DISTINCT(ACTION), AVG(DURATION) AS DUR + FROM {$TABLE_NAME} + GROUP BY ACTION + ORDER BY DUR DESC LIMIT 10"; + $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