[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r14508 - in gauger: . css
From: |
gnunet |
Subject: |
[GNUnet-SVN] r14508 - in gauger: . css |
Date: |
Thu, 24 Feb 2011 03:30:27 +0100 |
Author: bartpolot
Date: 2011-02-24 03:30:27 +0100 (Thu, 24 Feb 2011)
New Revision: 14508
Modified:
gauger/css/style.css
gauger/explore.php
gauger/plot.php
gauger/template.php
gauger/template_graph.php
Log:
Added normalization support
Modified: gauger/css/style.css
===================================================================
--- gauger/css/style.css 2011-02-23 18:20:50 UTC (rev 14507)
+++ gauger/css/style.css 2011-02-24 02:30:27 UTC (rev 14508)
@@ -242,6 +242,11 @@
float: right;
}
+#norm {
+ position: relative;
+ top: 2px;
+}
+
.footer-shadow {
height: 50px;
background-image: url("images/f.png");
Modified: gauger/explore.php
===================================================================
--- gauger/explore.php 2011-02-23 18:20:50 UTC (rev 14507)
+++ gauger/explore.php 2011-02-24 02:30:27 UTC (rev 14508)
@@ -59,6 +59,21 @@
return Array($b, $e);
}
+function get_local_maximum($h, $g, $s, $e) {
+ global $DATADIR;
+ $lm = false;
+ $f = @fopen("$DATADIR$h/$g.dat", 'r');
+ if ($f === false) return 1;
+ while (($buffer = fgets($f, 512)) !== false) {
+ $l = explode(' ', $buffer);
+ if($l[0] >= $s && $l[0] <= $e) {
+ if($lm === false || $l[1] > $lm) $lm = $l[1];
+ }
+ }
+ fclose($f);
+ return $lm ? $lm : 1;
+}
+
$d = dir($DATADIR);
$hosts = array();
$metrics = array();
Modified: gauger/plot.php
===================================================================
--- gauger/plot.php 2011-02-23 18:20:50 UTC (rev 14507)
+++ gauger/plot.php 2011-02-24 02:30:27 UTC (rev 14508)
@@ -26,8 +26,6 @@
* @return: gnuplot file with inline data
*/
function build_gnuplot_file($cmd, $rangecmd, $plotcmd) {
- $header = file_get_contents("header.gp");
- $cmd = preg_replace('/[^;]+; (.*)/', '\1', $cmd);
$files = explode(",", $plotcmd);
foreach ($files as $i => $file) {
$path = preg_replace('/[^"]+"([^"]+).*/', '\1', $file);
@@ -37,7 +35,6 @@
}
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename=source.gp');
- echo $header;
echo str_replace("; ", ";\n", $cmd) . "\n";
echo "$plotcmd;\n";
foreach($files as $file) {
@@ -65,14 +62,31 @@
global $hosts;
global $DATADIR;
- $cmd = 'load "header.gp";';
+ $cmd = 'set terminal png font "Arial,12";';
+ $cmd .= ' set grid;';
+ //$cmd .= ' set yrange[0:];';
+ $cmd .= ' set key below;';
+ $cmd .= ' set style lines 1 lt rgb "#A0A0A0" lw 2;';
+ $cmd .= ' set style lines 2 lt rgb "#404040" lw 1 pt 1;';
+ $cmd .= ' set style lines 3 lt rgb "green" lw 2;';
+ $cmd .= ' set style lines 4 lt rgb "red" lw 2;';
+ $cmd .= ' set style lines 5 lt rgb "blue" lw 2;';
+ $cmd .= ' set style lines 6 lt rgb "cyan" lw 2;';
+ $cmd .= ' set style lines 7 lt rgb "violet" lw 2;';
+ $cmd .= ' set style lines 8 lt rgb "orange" lw 2;';
+ $cmd .= ' set style increment user;';
+
$cmd .= ' set terminal png size ';
$cmd .= get_session('png_x_size', '640') . ',';
$cmd .= get_session('png_y_size', '480') . ';';
- if(!empty($g)) $cmd .= ' set ylabel "' . get_counter_unit($g[0]) . '";';
+ $norm = get_param('norm', '') == 'true';
+ if(!empty($g)) {
+ $cmd .= ' set ylabel "' . ($norm ? 'percentage' :
get_counter_unit($g[0])) . '";';
+ }
+
foreach (Array('x_max', 'x_min', 'y_max', 'y_min') as $param_name) {
- $$param_name = get_param($param_name, '',
false);//get_param('persist') == '1'
+ $$param_name = get_param($param_name, '', false);
if(!is_numeric($$param_name)) $$param_name = '*';
}
$cmd .= " set xrange [$x_min:$x_max];";
@@ -98,10 +112,25 @@
$range_end = get_param('xrange_min');
}
-
$plotcmd = ' plot';
$units = Array();
$c = 0;
+ if($x_min == '*' || $x_max == '*') {
+ foreach($h as $host) {
+ $counters = $hosts[$host];
+ if($cg == 0) $g = $counters;
+ foreach($g as $graph) {
+ if(array_search($graph, $counters) === FALSE) continue;
+ $r = get_range($host, $graph);
+ if($x_min == '*') {
+ $range_start = min($range_start, $r[0]);
+ }
+ if($x_max == '*') {
+ $range_end = max($range_end, $r[1]);
+ }
+ }
+ }
+ }
foreach($h as $host) {
$counters = $hosts[$host];
if($cg == 0) $g = $counters;
@@ -115,6 +144,10 @@
$counter = get_counter_name($graph);
if($c) $plotcmd .= ',';
$plotcmd .= " \"$DATADIR$host/$graph.dat\"";
+ if($norm) {
+ $metric_max = get_local_maximum($host, $graph, $range_start,
$range_end);
+ $plotcmd .= " using 1:($2*100/$metric_max)";
+ }
$plotcmd .= " title \"";
if($ch != 1) $plotcmd .= $host;
if($ch != 1 && $cg != 1) $plotcmd .= " - ";
@@ -123,30 +156,14 @@
$plotcmd .= " with lines lw 2";
if($ch == 1 && $cg == 1) $plotcmd .= ",
\"$DATADIR$host/$graph.dat\" notitle with yerrorbars lw 1";
$c++;
- if($x_min == '*') {
- $r = get_range($host, $graph);
- $range_start = min($range_start, $r[0]);
- }
- if($x_max == '*') {
- $r = get_range($host, $graph);
- $range_end = max($range_end, $r[1]);
- }
}
}
$size = get_param('png_x_size');
$gap = $range_end - $range_start;
$interval = ceil($gap/(abs($size-150)/50));
if($interval > $gap) $interval = $gap;
- //die( "$interval = round($gap/(($size-150)/60))");
$rangecmd = " set xtics $range_start,$interval,$range_end;";
- //$rangecmd .= " set x2label \"$gap $interval\";";
-// echo '<pre>';
-// print_r($hosts);
-// print_r($h);
-// print_r($g);
-// die($rangecmd);
-
if(!$c) {
header('Location: nodata.png');
die();
Modified: gauger/template.php
===================================================================
--- gauger/template.php 2011-02-23 18:20:50 UTC (rev 14507)
+++ gauger/template.php 2011-02-24 02:30:27 UTC (rev 14508)
@@ -175,6 +175,13 @@
});
}
});
+ $( "#norm" ).click(function () {
+ c = this;
+ $(this).parents("tr").find(".plot").each(function(){
+ //alert(this.src.replace(/&norm=[^&]+/g,
'')+"&norm="+c.checked);
+ this.src = this.src.replace(/&norm=[^&]+/g,
'')+"&norm="+c.checked;
+ });
+ });
});
function get_command(element) {
Modified: gauger/template_graph.php
===================================================================
--- gauger/template_graph.php 2011-02-23 18:20:50 UTC (rev 14507)
+++ gauger/template_graph.php 2011-02-24 02:30:27 UTC (rev 14508)
@@ -26,6 +26,8 @@
<?php endif; ?>
<?php endforeach; ?>
<br/><br/>
+ <span>Normalize<input type="checkbox" id="norm"/></span>
+ <br/><br/>
<a href="#" onclick="get_command(this); return false;" >Get
Source</a>
</th>
<td height="<?php echo get_session('png_y_size')+2 ?>" width="<?php
echo get_session('png_x_size')+2 ?>"><img class="plot" src="plot.php?g=<?php
echo $currentg ?>" alt="loading..."/></td>
@@ -34,4 +36,3 @@
<?php else: ?>
<h1>The graph "<?php echo $currentg ?>" is not present in any host.</h1>
<?php endif; ?>
-<p>TODO: Select hosts | Range | Normalize </p>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r14508 - in gauger: . css,
gnunet <=