add graph script

This commit is contained in:
Olaf Rempel 2006-08-03 17:57:11 +02:00
parent 7ab72054ad
commit 9db670ee11
2 changed files with 484 additions and 2 deletions

View File

@ -11,10 +11,10 @@ plugin p_uptime.so
plugin p_netdev.so
plugin p_mount.so
#plugin p_ctstat.so
plugin p_rtstat.so
#plugin p_rtstat.so
plugin p_random.so
rrd_dir rrd
rrd_dir /var/lib/rrd
step 10

482
sammler.php Normal file
View File

@ -0,0 +1,482 @@
<?php
define('CONFIG', 'sammler_graph.conf');
define('BASE_DIR', '/var/lib/rrd/');
define('RRDTOOL', '/usr/bin/rrdtool');
function setup_html($conf) {
echo "<html><head><title>sammler graph setup</title>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-15\"/>\n";
echo "</head><body>\n";
echo "<form method=\"POST\" action=\"{$_SERVER['SCRIPT_NAME']}?action=setup\">\n";
echo "<table>\n";
echo "<tr><td><b>Graph Height:</b></td>\n";
echo "<td><input type=\"text\" name=\"height\" value=\"{$conf['height']}\"></td></tr>\n";
echo "<tr><td><b>Graph Width:</b></td>\n";
echo "<td><input type=\"text\" name=\"width\" value=\"{$conf['width']}\"></td></tr>\n";
echo "<tr><td colspan=\"4\"><hr></td></tr>\n";
echo "<tr><td><b>Available Views:</b></td><td colspan=\"2\"></td><td><b>default</b></td></tr>\n";
foreach ($conf['views'] as $name => $value) {
echo "<tr><td>({$value}s)</td>\n";
echo "<td><input type=\"text\" name=\"views[$value]\" value=\"{$name}\"></td><td></td>\n";
if ($conf['default_view'] == $value)
echo "<td><input type=\"radio\" name=\"default_view\" value=\"{$value}\" checked=\"checked\"></td>\n";
else
echo "<td><input type=\"radio\" name=\"default_view\" value=\"{$value}\"></td>\n";
echo "</tr>\n";
}
echo "<tr><td><b>add view:</b></td><td><input type=\"text\" name=\"views[new]\"></td></tr>\n";
echo "<tr><td colspan=\"4\"><hr></td></tr>\n";
foreach ($conf['hosts'] as $hostid => $host) {
echo "<tr><td><b>Hostname:</b></td>\n";
echo "<td><input type=\"text\" name=\"hosts[{$hostid}][hostname]\" value=\"{$host['hostname']}\"></td>\n";
echo "<td><a href=\"{$_SERVER['SCRIPT_NAME']}?action=setup&sub=move_host_up&host={$hostid}\">up</a>&nbsp;\n";
echo "<a href=\"{$_SERVER['SCRIPT_NAME']}?action=setup&sub=move_host_down&host={$hostid}\">down</a></td>\n";
if ($host['show'])
echo "<td><input type=\"checkbox\" name=\"hosts[{$hostid}][show]\" checked=\"checked\">show</td>";
else
echo "<td><input type=\"checkbox\" name=\"hosts[{$hostid}][show]\">show</td>";
echo "</tr>\n";
foreach ($host['rrds'] as $rrdid => $rrd) {
echo "<tr><td>&nbsp;&nbsp;{$rrd['rrd']}</td>\n";
echo "<td><input type=\"text\" name=\"hosts[{$hostid}][rrds][{$rrdid}][title]\" value=\"{$rrd['title']}\"></td>\n";
echo "<td><a href=\"{$_SERVER['SCRIPT_NAME']}?action=setup&sub=move_rrd_up&host={$hostid}&rrd={$rrdid}\">up</a>&nbsp;\n";
echo "<a href=\"{$_SERVER['SCRIPT_NAME']}?action=setup&sub=move_rrd_down&host={$hostid}&rrd={$rrdid}\">down</a></td>\n";
if ($rrd['show'])
echo "<td><input type=\"checkbox\" name=\"hosts[{$hostid}][rrds][{$rrdid}][show]\" checked=\"checked\">show</td>";
else
echo "<td><input type=\"checkbox\" name=\"hosts[{$hostid}][rrds][{$rrdid}][show]\">show</td>";
echo "</tr>\n";
}
echo "<tr><td colspan=\"4\"><hr></td></tr>\n";
}
echo "<tr><td colspan=\"4\" align=\"center\">\n";
echo "<input type=\"button\" value=\"Show\" onClick=\"javascript:window.location.href='{$_SERVER['SCRIPT_NAME']}?action=show'\">&nbsp\n";
echo "<input type=\"submit\" value=\"Save Config\">&nbsp\n";
echo "<input type=\"button\" value=\"Rebuild Config\" onClick=\"javascript:window.location.href='{$_SERVER['SCRIPT_NAME']}?action=init'\">\n";
echo "</td></tr>\n";
echo "</table></form>\n";
echo "</body></html>\n";
}
function show_html($conf) {
echo "<html><head><title>Stats</title>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-15\"/>\n";
echo "</head><body>\n";
$hostid = isset($_GET['host']) ? $_GET['host'] : 0;
$view = isset($_GET['view']) ? $_GET['view'] : $conf['default_view'];
echo "<b>Select Host:</b>\n";
echo "<select name=\"host\" OnChange=\"document.location.href='{$_SERVER['SCRIPT_NAME']}?action=show&host='+this.value+'&view={$view}'\">\n";
foreach ($conf['hosts'] as $id => $host) {
if (!$host['show'])
continue;
if ($hostid == $id)
echo "<option value=\"{$id}\" selected=\"selected\">{$host['hostname']}</option>\n";
else
echo "<option value=\"{$id}\">{$host['hostname']}</option>\n";
}
echo "</select>&nbsp;\n";
echo "<td><select name=\"view\" OnChange=\"document.location.href='{$_SERVER['SCRIPT_NAME']}?action=show&host={$hostid}&view='+this.value\">\n";
foreach ($conf['views'] as $name => $value) {
if ($view == $value)
echo "<option value=\"{$value}\" selected=\"selected\">{$name}</option>\n";
else
echo "<option value=\"{$value}\">{$name}</option>\n";
}
echo "</select><br><br>\n";
foreach ($conf['hosts'][$hostid]['rrds'] as $rrdid => $rrd) {
if (!$rrd['show'])
continue;
echo "<img src=\"{$_SERVER['SCRIPT_NAME']}?action=rrd&host={$hostid}&rrd={$rrdid}&view={$view}\" border=\"0\"><br><br>\n";
}
echo "</body></html>\n";
}
function read_config($filename) {
$handle = @fopen($filename, "r");
if ($handle !== false && filesize($filename) > 0) {
$contents = fread($handle, filesize($filename));
fclose($handle);
return unserialize($contents);
}
}
function write_config($filename, $config) {
$handle = fopen($filename, "w+");
if ($handle !== false) {
$contents = serialize($config);
fwrite($handle, $contents);
fclose($handle);
}
}
function get_hostdirs() {
$retval = array();
$dh = opendir(BASE_DIR);
while (($file = readdir($dh)) !== false)
if (is_dir(BASE_DIR.$file) && $file != "." && $file != "..")
$retval[] = $file;
closedir($dh);
return $retval;
}
function get_rrdfiles($directory) {
$retval = array();
$dh = opendir(BASE_DIR.$directory);
while (($file = readdir($dh)) !== false) {
if (is_dir(BASE_DIR.$file))
continue;
if (strstr($file, "rrd") !== false)
$retval[] = $file;
}
closedir($dh);
return $retval;
}
function create_config() {
$conf = array();
$conf['default_view'] = 86400;
$conf['views'] = array("6 hours" => 21600, "1 day" => 86400, "1 week" => 604800, "1 month" => 2678400);
$conf['height'] = 80;
$conf['width'] = 400;
$conf['hosts'] = array();
$rrds = array();
$tmp = get_rrdfiles('');
foreach ($tmp as $file) {
$rrds[] = array(
'show' => true,
'title' => str_replace(".rrd", "", basename($file)),
'rrd' => $file,
);
}
$conf['hosts'][] = array(
'hostname' => 'localhost',
'show' => true,
'rrds' => $rrds,
);
$hosts = get_hostdirs();
foreach ($hosts as $host) {
$rrds = array();
$tmp = get_rrdfiles($host);
foreach ($tmp as $file) {
$rrds[] = array(
'show' => true,
'title' => str_replace(".rrd", "", basename($file)),
'rrd' => "$host/$file",
);
}
$conf['hosts'][] = array(
'hostname' => $host,
'show' => true,
'rrds' => $rrds,
);
}
return $conf;
}
function setup($conf) {
if (isset($_GET['sub']) && $_GET['sub'] == "move_host_up") {
$hostid = isset($_GET['host']) ? $_GET['host'] : -1;
if (isset($conf['hosts'][$hostid]) && isset($conf['hosts'][$hostid -1])) {
$a = $conf['hosts'][$hostid];
$b = $conf['hosts'][$hostid -1];
$conf['hosts'][$hostid] = $b;
$conf['hosts'][$hostid -1] = $a;
}
return $conf;
} else if (isset($_GET['sub']) && $_GET['sub'] == "move_host_down") {
$hostid = isset($_GET['host']) ? $_GET['host'] : -1;
if (isset($conf['hosts'][$hostid]) && isset($conf['hosts'][$hostid +1])) {
$a = $conf['hosts'][$hostid];
$b = $conf['hosts'][$hostid +1];
$conf['hosts'][$hostid] = $b;
$conf['hosts'][$hostid +1] = $a;
}
return $conf;
} else if (isset($_GET['sub']) && $_GET['sub'] == "move_rrd_up") {
$hostid = isset($_GET['host']) ? $_GET['host'] : -1;
$rrdid = isset($_GET['rrd']) ? $_GET['rrd'] : -1;
if (isset($conf['hosts'][$hostid]['rrds'][$rrdid]) && isset($conf['hosts'][$hostid]['rrds'][$rrdid -1])) {
$a = $conf['hosts'][$hostid]['rrds'][$rrdid];
$b = $conf['hosts'][$hostid]['rrds'][$rrdid -1];
$conf['hosts'][$hostid]['rrds'][$rrdid] = $b;
$conf['hosts'][$hostid]['rrds'][$rrdid -1] = $a;
}
return $conf;
} else if (isset($_GET['sub']) && $_GET['sub'] == "move_rrd_down") {
$hostid = isset($_GET['host']) ? $_GET['host'] : -1;
$rrdid = isset($_GET['rrd']) ? $_GET['rrd'] : -1;
if (isset($conf['hosts'][$hostid]['rrds'][$rrdid]) && isset($conf['hosts'][$hostid]['rrds'][$rrdid +1])) {
$a = $conf['hosts'][$hostid]['rrds'][$rrdid];
$b = $conf['hosts'][$hostid]['rrds'][$rrdid +1];
$conf['hosts'][$hostid]['rrds'][$rrdid] = $b;
$conf['hosts'][$hostid]['rrds'][$rrdid +1] = $a;
}
return $conf;
} else if (!empty($_POST)) {
$conf['default_view'] = $_POST['default_view'];
$conf['height'] = $_POST['height'];
$conf['width'] = $_POST['width'];
$conf['views'] = array();
foreach ($_POST['views'] as $name) {
if (empty($name))
continue;
$tmp = strtotime($name);
if ($tmp != -1)
$conf['views'][$name] = $tmp - time();
}
natsort($conf['views']);
foreach ($_POST['hosts'] as $hostid => $host) {
$conf['hosts'][$hostid]['hostname'] = $host['hostname'];
$conf['hosts'][$hostid]['show'] = ($host['show'] == "on");
foreach ($host['rrds'] as $rrdid => $rrd) {
$conf['hosts'][$hostid]['rrds'][$rrdid]['title'] = $_POST['hosts'][$hostid]['rrds'][$rrdid]['title'];
$conf['hosts'][$hostid]['rrds'][$rrdid]['show'] = ($_POST['hosts'][$hostid]['rrds'][$rrdid]['show'] == "on");
}
}
return $conf;
} else {
setup_html($conf);
}
}
function show_rrd($conf) {
$hostid = isset($_GET['host']) ? $_GET['host'] : -1;
$rrdid = isset($_GET['rrd']) ? $_GET['rrd'] : -1;
if (!isset($conf['hosts'][$hostid]['rrds'][$rrdid]['rrd']))
return;
$view = isset($_GET['view']) ? -$_GET['view'] : -$conf['default_view'];
$rrdfile = BASE_DIR.$conf['hosts'][$hostid]['rrds'][$rrdid]['rrd'];
$title = $conf['hosts'][$hostid]['rrds'][$rrdid]['title'];
$height = $conf['height'];
$width = $conf['width'];
$cmd = RRDTOOL." graph - --imgformat PNG --start {$view} --end -10 --title \"{$title}\" --rigid ";
$tmp = explode('-', basename($rrdfile));
$tmp = explode('_', $tmp[0]);
$tmp = explode('.', $tmp[0]);
switch ($tmp[0]) {
case 'cpu':
$height *= 2;
$cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"percent\" ".
"DEF:a={$rrdfile}:user:AVERAGE ".
"DEF:b={$rrdfile}:nice:AVERAGE ".
"DEF:c={$rrdfile}:syst:AVERAGE ".
"DEF:d={$rrdfile}:idle:AVERAGE ".
"DEF:e={$rrdfile}:wait:AVERAGE ".
"DEF:f={$rrdfile}:intr:AVERAGE ".
"DEF:g={$rrdfile}:sitr:AVERAGE ".
'AREA:c#FF0000:"System " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:f#EA8F00:"IRQ " GPRINT:f:LAST:"Current\:%8.2lf %s" GPRINT:f:AVERAGE:"Average\:%8.2lf %s" GPRINT:f:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:g#FFFF00:"Soft-IRQ" GPRINT:g:LAST:"Current\:%8.2lf %s" GPRINT:g:AVERAGE:"Average\:%8.2lf %s" GPRINT:g:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:e#0000FF:"IO-Wait " GPRINT:e:LAST:"Current\:%8.2lf %s" GPRINT:e:AVERAGE:"Average\:%8.2lf %s" GPRINT:e:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:a#00CFCF:"User " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:b#00CF00:"Nice " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" ';
break;
case 'load':
$cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"load\" ".
"DEF:a={$rrdfile}:1min:AVERAGE ".
"DEF:b={$rrdfile}:5min:AVERAGE ".
"DEF:c={$rrdfile}:15min:AVERAGE ".
'CDEF:x=a,b,c,MAX,MAX '.
'AREA:a#EACC00:"1 Minute Average " GPRINT:a:LAST:"Current\:%8.2lf %s\n" '.
'AREA:b#EA8F00:"5 Minute Average " GPRINT:b:LAST:"Current\:%8.2lf %s\n" '.
'AREA:c#FF0000:"15 Minute Average" GPRINT:c:LAST:"Current\:%8.2lf %s\n" '.
'LINE1:x#404040:"Total"';
break;
case 'memory':
$cmd .= "--base=1024 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"kB\" ".
"DEF:aa={$rrdfile}:total:AVERAGE ".
"DEF:bb={$rrdfile}:free:AVERAGE ".
"DEF:cc={$rrdfile}:buffers:AVERAGE ".
"DEF:dd={$rrdfile}:cached:AVERAGE ".
'CDEF:a=aa,1024,* '.
'CDEF:b=bb,1024,* '.
'CDEF:c=cc,1024,* '.
'CDEF:d=dd,1024,* '.
'CDEF:x=aa,bb,cc,dd,+,+,-,1024,* '.
'CDEF:xc=x,c,+ '.
'CDEF:xcd=x,c,d,+,+ '.
'LINE1:a#000000:"Total Memory " GPRINT:a:LAST:"Current\:%8.2lf %s\n" '.
'AREA:x#FF0000:"Used Memory " GPRINT:x:LAST:"Current\:%8.2lf %s" GPRINT:x:AVERAGE:"Average\:%8.2lf %s" GPRINT:x:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:c#FF7D00:"Buffer Memory " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:d#FFC73B:"Cache Memory " GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:b#00CF00:"Free Memory " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s" '.
'LINE1:x#404040 LINE1:xc#404040 LINE1:xcd#404040';
break;
case 'mount':
$cmd .= "--base=1024 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"kB\" ".
"DEF:aa={$rrdfile}:block_total:AVERAGE ".
"DEF:cc={$rrdfile}:block_free:AVERAGE ".
'CDEF:a=aa,1024,* '.
'CDEF:b=aa,cc,-,1024,* '.
'CDEF:c=cc,1024,* '.
'LINE1:a#000000:"Total " GPRINT:a:LAST:"Current\:%8.2lf %s\n" '.
'AREA:b#FF0000:"Used " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:c#00CF00:"Free " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s" '.
'LINE1:b#404040 ';
break;
case 'net':
$height *= 2;
$cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"bytes per second\" ".
"DEF:imax={$rrdfile}:byte_in:MAX ".
"DEF:iavg={$rrdfile}:byte_in:AVERAGE ".
"DEF:imin={$rrdfile}:byte_in:MIN ".
"DEF:omax={$rrdfile}:byte_out:MAX ".
"DEF:oavg={$rrdfile}:byte_out:AVERAGE ".
"DEF:omin={$rrdfile}:byte_out:MIN ".
'CDEF:omaxn=omax,-1,* CDEF:oavgn=oavg,-1,* CDEF:ominn=omin,-1,* '.
'CDEF:imid=imax,imin,- CDEF:omid=omaxn,ominn,- '.
'HRULE:0#FF0000 '.
'AREA:imin STACK:imid#A0FFA0:"min/max Inbound " GPRINT:imin:MIN:"%6.2lf%s" GPRINT:imax:MAX:"%6.2lf%s" '.
'LINE1:imin#a0a0a0 LINE1:imax#a0a0a0 LINE1:iavg#008000:"avg Inbound " '.
'GPRINT:iavg:MIN:"min\: %6.2lf%s" GPRINT:iavg:AVERAGE:"avg\: %6.2lf%s" GPRINT:iavg:MAX:"max\: %6.2lf%s\n" '.
'AREA:ominn STACK:omid#C0C0FF:"min/max Outbound" GPRINT:omin:MIN:"%6.2lf%s" GPRINT:omax:MAX:"%6.2lf%s" '.
'LINE1:ominn#a0a0a0 LINE1:omaxn#a0a0a0 LINE1:oavgn#000080:"avg Outbound" '.
'GPRINT:oavg:MIN:"min\: %6.2lf%s" GPRINT:oavg:AVERAGE:"avg\: %6.2lf%s" GPRINT:oavg:MAX:"max\: %6.2lf%s\n" ';
break;
case 'proc':
$cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"per second\" ".
"DEF:a={$rrdfile}:intr:AVERAGE ".
"DEF:b={$rrdfile}:ctxt:AVERAGE ".
"DEF:c={$rrdfile}:fork:AVERAGE ".
'AREA:b#00AF00:"Context " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:a#FF0000:"Interrupts" GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:c#0000FF:"Forks " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" ';
break;
case 'random':
$cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit 0 --vertical-label=\"bytes\" ".
"DEF:a={$rrdfile}:entropy:AVERAGE ".
'AREA:a#00CF00:"Available Entropy" GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s" '.
'LINE1:a#404040 ';
break;
case 'swap':
$cmd .= "--base=1024 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"kB\" ".
"DEF:aa={$rrdfile}:total:AVERAGE ".
"DEF:bb={$rrdfile}:free:AVERAGE ".
'CDEF:a=aa,1024,* '.
'CDEF:b=bb,1024,* '.
'CDEF:x=aa,bb,-,1024,* '.
'LINE1:a#000000:"Total Swap " GPRINT:a:LAST:"Current\:%8.2lf %s\n" '.
'AREA:x#FF0000:"Used Swap " GPRINT:x:LAST:"Current\:%8.2lf %s" GPRINT:x:AVERAGE:"Average\:%8.2lf %s" GPRINT:x:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:b#00CF00:"Free Swap " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" ';
break;
case 'uptime':
$cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit 0 --vertical-label=\"days\" ".
"DEF:ups={$rrdfile}:uptime:AVERAGE ".
"DEF:idles={$rrdfile}:idletime:AVERAGE ".
'CDEF:up=ups,86400,/ '.
'CDEF:idle=idles,86400,/ '.
'AREA:up#00CF00:"Uptime " '.
'LINE1:idle#002A97:"Idletime "';
break;
case 'vmstat':
$height *= 2;
$cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"allocs\" ".
"DEF:a={$rrdfile}:pgalloc_high:AVERAGE ".
"DEF:b={$rrdfile}:pgalloc_normal:AVERAGE ".
"DEF:c={$rrdfile}:pgalloc_dma:AVERAGE ".
"DEF:d={$rrdfile}:pgfree:AVERAGE ".
"DEF:e={$rrdfile}:pgfault:AVERAGE ".
"CDEF:ee=e,-1,* ".
'AREA:c#FF0000:"pgalloc_dma " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:b#00CF00:"pgalloc_normal " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
'STACK:a#00CFCF:"pgalloc_high " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
'LINE1:d#FF7D00:"pgfree " GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" '.
'AREA:ee#0040FF:"pgfault " GPRINT:e:LAST:"Current\:%8.2lf %s" GPRINT:e:AVERAGE:"Average\:%8.2lf %s" GPRINT:e:MAX:"Maximum\:%8.2lf %s" '.
'LINE1:ee#002A97 ';
break;
}
header('Content-type: image/x-png');
passthru($cmd);
die();
}
$action = $_GET['action'];
switch ($action) {
case 'init':
$conf = create_config();
write_config(CONFIG, $conf);
header("Location: {$_SERVER['SCRIPT_NAME']}?action=setup");
break;
case 'setup':
$conf = read_config(CONFIG);
$conf = setup($conf);
if (isset($conf)) {
write_config(CONFIG, $conf);
header("Location: {$_SERVER['SCRIPT_NAME']}?action=setup");
}
break;
case 'rrd':
$conf = read_config(CONFIG);
show_rrd($conf);
break;
default:
case 'show':
$conf = read_config(CONFIG);
show_html($conf);
break;
}
?>