2007-04-03 14:10:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function cpugraphHP ($rrd, $graph , $from, $to, $width, $height)
|
|
|
|
{
|
2009-10-28 13:49:37 +00:00
|
|
|
global $config;
|
2007-04-03 14:10:23 +00:00
|
|
|
$database = "rrd/" . $rrd;
|
|
|
|
$optsa = array( "--start", $from, "--width", $width, "--height", $height, "--vertical-label", $vertical, "--alt-autoscale-max",
|
|
|
|
"-l 0",
|
|
|
|
"-E",
|
|
|
|
"--title", $title,
|
|
|
|
"DEF:load=$database:LOAD:AVERAGE",
|
|
|
|
"AREA:load#FAFDCE:",
|
|
|
|
"LINE1.25:load#dd8800:Load",
|
|
|
|
"GPRINT:load:LAST:Cur\:%3.2lf",
|
|
|
|
"GPRINT:load:AVERAGE:Avg\:%3.2lf",
|
|
|
|
"GPRINT:load:MIN:Min\:%3.2lf",
|
|
|
|
"GPRINT:load:MAX:Max\:%3.2lf\\n");
|
|
|
|
|
2008-04-10 14:52:51 +00:00
|
|
|
if($width <= "300") {$optsb = array("--font", "LEGEND:7:".$config['mono_font']."",
|
|
|
|
"--font", "AXIS:6:".$config['mono_font']."",
|
2007-04-03 14:10:23 +00:00
|
|
|
"--font-render-mode", "normal");}
|
2007-11-23 11:37:28 +00:00
|
|
|
$opts = array_merge($config['rrdgraph_defaults'], $$optsa, $optsb);
|
2007-04-03 14:10:23 +00:00
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
$ret = rrd_graph("$graph", $opts, count($opts));
|
2007-04-03 14:10:23 +00:00
|
|
|
|
|
|
|
if( !is_array($ret) ) {
|
|
|
|
$err = rrd_error();
|
|
|
|
#echo "rrd_graph() ERROR: $err\n";
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
2009-10-28 13:49:37 +00:00
|
|
|
return $graph;
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function memgraphHP ($rrd, $graph , $from, $to, $width, $height, $title, $vertical)
|
|
|
|
{
|
2008-04-10 14:52:51 +00:00
|
|
|
global $config, $installdir;
|
2007-04-03 14:10:23 +00:00
|
|
|
$database = "rrd/" . $rrd;
|
2009-10-28 13:49:37 +00:00
|
|
|
|
2007-04-03 14:10:23 +00:00
|
|
|
$memrrd = $database;
|
2007-11-23 11:37:28 +00:00
|
|
|
$opts = array("--start", "$from", "--alt-autoscale-max", "--width", "$width", "--height", "$height",
|
|
|
|
"-l", "0", "-E", "-b", "1024",
|
|
|
|
"DEF:TOTAL=$memrrd:TOTAL:AVERAGE",
|
|
|
|
"DEF:FREE=$memrrd:FREE:AVERAGE",
|
|
|
|
"DEF:USED=$memrrd:USED:AVERAGE",
|
|
|
|
"AREA:USED#ee9900:Used",
|
|
|
|
"AREA:FREE#FAFDCE:Free:STACK",
|
|
|
|
"LINE1.5:TOTAL#cc0000:");
|
2007-04-03 14:10:23 +00:00
|
|
|
|
2008-04-10 14:52:51 +00:00
|
|
|
if($width <= "300") {$optsb = array("--font", "LEGEND:7:".$config['mono_font']."",
|
|
|
|
"--font", "AXIS:6:".$config['mono_font']."",
|
2007-11-23 11:37:28 +00:00
|
|
|
"--font-render-mode", "normal");}
|
2007-04-03 14:10:23 +00:00
|
|
|
|
2007-11-23 11:37:28 +00:00
|
|
|
$opts = array_merge($config['rrdgraph_defaults'], $$opts, $optsb);
|
2007-04-03 14:10:23 +00:00
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
$ret = rrd_graph("$graph", $opts, count($opts));
|
2007-11-23 11:37:28 +00:00
|
|
|
|
|
|
|
if( !is_array($ret) ) {
|
|
|
|
$err = rrd_error();
|
|
|
|
#echo "rrd_graph() ERROR: $err\n";
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
2009-10-28 13:49:37 +00:00
|
|
|
return $graph;
|
2007-11-23 11:37:28 +00:00
|
|
|
}
|
|
|
|
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
|