bcast-bridge/web/include/Graphs.class.php

46 lines
2.0 KiB
PHP
Raw Normal View History

2006-12-22 00:06:05 +01:00
<?php
class Graphs {
private function show($title, $view, $param) {
header('Content-type: image/x-png');
passthru(RRDTOOL." graph - --imgformat PNG --start -{$view} --end -10 --title \"{$title}\" --rigid {$param}");
}
public function hlsw($rrdpath, $title, $view, $height, $width) {
$rrdfile = RRDPATH.'/'.$rrdpath;
$cmd = "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"bytes\" ".
"DEF:a={$rrdfile}:from:AVERAGE ".
"DEF:b={$rrdfile}:to:AVERAGE ".
'CDEF:bb=b,-1,* '.
'AREA:a#008000:"from hlsw" GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n" '.
'HRULE:0#ff0000: '.
'AREA:bb#000080:"to hlsw" GPRINT:b:LAST:"Current\:%8.0lf" GPRINT:b:AVERAGE:"Average\:%8.0lf" GPRINT:b:MAX:"Maximum\:%8.0lf\n" '.
'';
self::show($title, $view, $cmd);
}
public function vlan($rrdpath, $title, $view, $height, $width) {
$rrdfile = RRDPATH.'/'.$rrdpath;
$cmd = "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"bytes\" ".
"DEF:a={$rrdfile}:loop:AVERAGE ".
"DEF:b={$rrdfile}:arp:AVERAGE ".
"DEF:c={$rrdfile}:nonip:AVERAGE ".
"DEF:d={$rrdfile}:block:AVERAGE ".
"DEF:e={$rrdfile}:fwd:AVERAGE ".
"DEF:f={$rrdfile}:out:AVERAGE ".
'AREA:a#FF0000:"loop " GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n" '.
'STACK:b#EA8F00:"arp " GPRINT:b:LAST:"Current\:%8.0lf" GPRINT:b:AVERAGE:"Average\:%8.0lf" GPRINT:b:MAX:"Maximum\:%8.0lf\n" '.
'STACK:c#FFFF00:"nonip " GPRINT:c:LAST:"Current\:%8.0lf" GPRINT:c:AVERAGE:"Average\:%8.0lf" GPRINT:c:MAX:"Maximum\:%8.0lf\n" '.
'STACK:d#0000FF:"blocked " GPRINT:d:LAST:"Current\:%8.0lf" GPRINT:d:AVERAGE:"Average\:%8.0lf" GPRINT:d:MAX:"Maximum\:%8.0lf\n" '.
'STACK:e#00CF00:"forwarded" GPRINT:e:LAST:"Current\:%8.0lf" GPRINT:e:AVERAGE:"Average\:%8.0lf" GPRINT:e:MAX:"Maximum\:%8.0lf\n" '.
'';
self::show($title, $view, $cmd);
}
}
?>