summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a26b5d4)
raw | patch | inline | side by side (parent: a26b5d4)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 24 Aug 2010 15:17:16 +0000 (15:17 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 24 Aug 2010 15:17:16 +0000 (15:17 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19444 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/plugins/generic/statistics/chartClasses/class_pieChart1.inc | [new file with mode: 0644] | patch | blob |
gosa-core/plugins/generic/statistics/chartClasses/class_pieChart2.inc | [new file with mode: 0644] | patch | blob |
gosa-core/plugins/generic/statistics/class_statistics.inc | patch | blob | history | |
gosa-core/plugins/generic/statistics/statistics.tpl | patch | blob | history |
diff --git a/gosa-core/plugins/generic/statistics/chartClasses/class_pieChart1.inc b/gosa-core/plugins/generic/statistics/chartClasses/class_pieChart1.inc
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+
+class pieChart1 extends statChart
+{
+ var $title = 'Plugin usage';
+ var $enableCaching = FALSE;
+
+ var $keyName = "actionsPerCategory";
+
+
+ function __construct(&$config)
+ {
+ parent::__construct($config);
+ $this->graphName = get_class();
+ }
+
+ /*! \brief Generate the pie-chart which displays the overall-plugin-usage
+ */
+ function render()
+ {
+ // Do nothing, if we've no data.
+ $data = array();
+ if(isset($this->graphData[$this->keyName]) && count($this->graphData[$this->keyName])){
+ $data = $this->graphData[$this->keyName];
+ }
+
+ // Sort data by usage count and slice array to get
+ // the eight most used categories
+ arsort($data);
+
+ // Detect max value and throw out entries less than 1%
+ // the will else be unreadable
+ $max = max($data);
+ $pos = 0;
+ foreach($data as $key => $count){
+ if($pos >=7 || ($count / $max)*100 < 1) break;
+ $pos ++;
+ }
+
+ $dataRes = array_slice($data,0,$pos);
+
+ // Get the rest of categories and combine them 'others'
+ $theRest = array_slice($data,$pos);
+ $dataRes['remaining'] = array_sum($theRest);
+
+ // Try to find a translation for the given category names
+ $values = array_values($dataRes);
+ $keys = array_keys($dataRes);
+ foreach($keys as $id => $cat){
+ $keys[$id] = $this->getCategoryTranslation($cat);
+ }
+
+ // Dataset definition
+ $dataSet = new pData;
+ $dataSet->AddPoint($values,"Serie1");
+ $dataSet->AddAllSeries();
+ $dataSet->AddPoint($keys,"Serie2");
+ $dataSet->SetAbsciseLabelSerie("Serie2");
+
+ // Read graph from cache?
+ $pCache = new pCache('/var/spool/gosa/');
+ if($this->enableCaching && $pCache->IsInCache(get_class(),$dataSet->GetData())){
+ $filename = $pCache->GetHash(get_class(),$dataSet->GetData());
+ $filename = '/var/spool/gosa/'.$filename;
+ if(file_exists($filename) && is_readable($filename)){
+ $this->graphID = preg_replace("/[^0-9]/","",microtime(TRUE)).rand(0,99999);
+ session::set('statistics::graphFile'.$this->graphID,$filename);
+ return;
+ }
+ }
+
+ // Set graph area
+ $x = 400;
+ $y = 200;
+
+ // Initialise the graph
+ $chart = new pChart($x,$y);
+ $chart->setFontProperties($this->font,10);
+ if(count($data)) {
+ $chart->drawPieGraph($dataSet->GetData(),$dataSet->GetDataDescription(),($x/3),($y/2)-10,($y/2),PIE_PERCENTAGE,TRUE,50,20,6);
+ }
+ $chart->drawPieLegend(($x/3*2),15,$dataSet->GetData(),$dataSet->GetDataDescription(),255,255,255);
+
+ // Store graph data
+ $this->graphID = preg_replace("/[^0-9]/","",microtime(TRUE));
+ $file = '/tmp/graph_'.$this->graphID;
+ $chart->Render($file);
+ session::set('statistics::graphFile'.$this->graphID,$file);
+ $pCache->WriteToCache(get_class(),$dataSet->GetData(),$chart);
+ }
+}
+?>
diff --git a/gosa-core/plugins/generic/statistics/chartClasses/class_pieChart2.inc b/gosa-core/plugins/generic/statistics/chartClasses/class_pieChart2.inc
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+class pieChart2 extends pieChart1
+{
+ var $title = 'Action usage';
+ var $enableCaching = FALSE;
+
+ var $keyName = "actionsPerPluginAction";
+
+ function __construct(&$config)
+ {
+ parent::__construct($config);
+ $this->graphName = get_class();
+ }
+}
+?>
diff --git a/gosa-core/plugins/generic/statistics/class_statistics.inc b/gosa-core/plugins/generic/statistics/class_statistics.inc
index 0794bb42574a281166ef4b1e1d30c20818449c31..25f9259b3f1601f17ddeda912f1d38a781c2f1ba 100644 (file)
$this->graphs[] = new categoryActionsOverTime($config);
$this->graphs[] = new memoryUsageChart($config);
+ $this->graphs[] = new cpuLoadChart($config);
+ $this->graphs[] = new renderTimeChart($config);
+ $this->graphs[] = new durationTimeChart($config);
+ $this->graphs[] = new pieChart1($config);
+ $this->graphs[] = new pieChart2($config);
// Init start and stop times for graph 1
$this->graph1DatePicker1 = date('d.m.Y', time() - 14 * 24 * 60 *60);
if(!count($gData)){
return;
}
- $this->generatePieGraph($gData['actionsPerCategory'], 1, _("Plugin usage"));
- $this->generatePieGraph($gData['actionsPerPluginAction'], 7,_("Actions"));
-
$curGraph = $this->graphs[$this->selectedGraphType];
$curGraph->setGraphData($gData);
$curGraph->render();
# $this->generateActionsGraph($gData);
-# // Generate graph which displays the memory usage over time
-# $series = array(
-# 'max_mem' => _('Max'),
-# 'avg_mem' => _('Avergae'),
-# 'min_mem' => _('Min'));
-# $this->generateSystemStatsGraph($gData,'usagePerInterval',$series, _("Memory usage"),3);
-#
-# // Generate graph which displays the cpu load over time
-# $series = array(
-# 'max_load' => _('Max'),
-# 'avg_load' => _('Avergae'),
-# 'min_load' => _('Min'));
-# $this->generateSystemStatsGraph($gData,'usagePerInterval',$series, _("CPU load"),4);
-#
# // Generate graph which displays the render time
# $series = array(
# 'max_render' => _('Max'),
- /*! \brief Generates a graph about system informations.
- */
- function generateSystemStatsGraph($gData, $key = "", $series= array(), $title = "", $gID=0 )
- {
- // Add series data to dataSet
- $dataSet = new pData;
- $max = 0;
- foreach($series as $seriesName => $seriesDesc){
- if(isset($gData[$key][$seriesName])){
- $dataSet->AddPoint($gData[$key][$seriesName],$seriesName);
- $dataSet->SetSerieName($seriesDesc,$seriesName);
- if($max < max($gData[$key][$seriesName])) $max = max($gData[$key][$seriesName]);
- }
- }
- $dataSet->AddAllSeries();
- $dataSet->AddPoint($gData['dates'], 'date');
- $dataSet->SetAbsciseLabelSerie('date');
-
- $chart = new pChart(800,230);
- $chart->setFixedScale(0.0001,($max*1.1));
- $chart->setFontProperties("./themes/default/fonts/LiberationSans-Regular.ttf",10);
- $chart->setGraphArea(50,30,585,200);
- $chart->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
- $chart->drawRoundedRectangle(5,5,695,225,5,230,230,230);
- $chart->drawGraphArea(255,255,255,TRUE);
- $chart->drawGrid(4,TRUE,200,200,200,50);
- $chart->drawTreshold(0,143,55,72,TRUE,TRUE);
- $chart->drawTitle(50,22,$title,50,50,50,585);
- $chart->drawLegend(650,30,$dataSet->GetDataDescription(),255,255,255);
-
- $chart->drawScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2, FALSE);
- $chart->drawFilledCubicCurve($dataSet->GetData(),$dataSet->GetDataDescription(),.1,50);
-
- $this->graphIDs[$gID] = preg_replace("/[^0-9]/","",microtime(TRUE));
- $file = '/tmp/graph_'.$this->graphIDs[$gID];
- $chart->Render($file);
- session::set('statistics::graphFile'.$this->graphIDs[$gID],$file);
- }
-
/*! \brief Generate the pie-chart which displays the overall-plugin-usage
*/
diff --git a/gosa-core/plugins/generic/statistics/statistics.tpl b/gosa-core/plugins/generic/statistics/statistics.tpl
index 50801a60ff3483f3d4c4a838b738e4483f72ae34..2c26ab0fe04d915adebd6426414d977faad688ff 100644 (file)
</table>
{if isset($curGraphID) && $curGraphID}
-
- <select name='selectedGraphType' onChange="document.mainform.submit();">
+ <select name='selectedGraphType' onChange="document.mainform.submit();" size='1'>
{html_options options=$availableGraphs selected=$selectedGraphType}
</select>
-
<hr>
<table>
<tr>
</tr>
</table>
{/if}
-
-
- {if isset($graphIDs.3) && $graphIDs.3}
- <img src='plugins/statistics/getGraph.php?id={$graphIDs.3}'>
- <hr>
- {/if}
- {if isset($graphIDs.4) && $graphIDs.4}
- <img src='plugins/statistics/getGraph.php?id={$graphIDs.4}'>
- <hr>
- {/if}
- {if isset($graphIDs.5) && $graphIDs.5}
- <img src='plugins/statistics/getGraph.php?id={$graphIDs.5}'>
- <hr>
- {/if}
- {if isset($graphIDs.6) && $graphIDs.6}
- <img src='plugins/statistics/getGraph.php?id={$graphIDs.6}'>
- <hr>
- {/if}
-
{/if}