\n"; echo "\n"; echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; foreach ($conf['views'] as $name => $value) { echo "\n"; echo "\n"; if ($conf['default_view'] == $value) echo "\n"; else echo "\n"; echo "\n"; } echo "\n"; echo "\n"; foreach ($conf['hosts'] as $hostid => $host) { echo "\n"; echo "\n"; echo "\n"; if ($host['show']) echo ""; else echo ""; echo "\n"; foreach ($host['rrds'] as $rrdid => $rrd) { echo "\n"; echo "\n"; echo "\n"; if ($rrd['show']) echo ""; else echo ""; echo "\n"; } echo "\n"; } echo "\n"; echo "
Graph Height:
Graph Width:

Available Views:default
({$value}s)
add view:

Hostname:up \n"; echo "downshowshow
  {$rrd['rrd']}up \n"; echo "downshowshow

\n"; echo " \n"; echo " \n"; echo "\n"; echo "
\n"; echo "\n"; } function show_html($conf) { echo "Stats\n"; echo "\n"; echo "\n"; $hostid = isset($_GET['host']) ? $_GET['host'] : 0; $view = isset($_GET['view']) ? $_GET['view'] : $conf['default_view']; echo "Select Host:\n"; echo " \n"; echo "

\n"; foreach ($conf['hosts'][$hostid]['rrds'] as $rrdid => $rrd) { if (!$rrd['show']) continue; echo "

\n"; } echo "\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); natsort($retval); 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); natsort($retval); 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, ); } $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}:system:AVERAGE ". "DEF:d={$rrdfile}:idle:AVERAGE ". "DEF:e={$rrdfile}:iowait:AVERAGE ". "DEF:f={$rrdfile}:irq:AVERAGE ". "DEF:g={$rrdfile}:softirq:AVERAGE ". "DEF:h={$rrdfile}:steal:AVERAGE ". "DEF:amax={$rrdfile}:user:MAX ". "DEF:bmax={$rrdfile}:nice:MAX ". "DEF:cmax={$rrdfile}:system:MAX ". "DEF:dmax={$rrdfile}:idle:MAX ". "DEF:emax={$rrdfile}:iowait:MAX ". "DEF:fmax={$rrdfile}:irq:MAX ". "DEF:gmax={$rrdfile}:softirq:MAX ". "DEF:hmax={$rrdfile}:steal:MAX ". "CDEF:allmax=amax,bmax,cmax,dmax,emax,fmax,gmax,hmax,+,+,+,+,+,+,+ ". 'AREA:allmax#C0C0C0 LINE:allmax#808080 '. 'AREA:h#000000:"Stolen " GPRINT:h:LAST:"Current\:%8.2lf %s" GPRINT:h:AVERAGE:"Average\:%8.2lf %s" GPRINT:h:MAX:"Maximum\:%8.2lf %s\n" '. 'STACK: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 'ctstat': $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"calls\" ". "DEF:a={$rrdfile}:searched:AVERAGE ". "DEF:b={$rrdfile}:found:AVERAGE ". "DEF:c={$rrdfile}:new:AVERAGE ". "DEF:d={$rrdfile}:invalid:AVERAGE ". "DEF:e={$rrdfile}:ignore:AVERAGE ". "DEF:f={$rrdfile}:delete:AVERAGE ". "DEF:g={$rrdfile}:delete_list:AVERAGE ". "DEF:h={$rrdfile}:insert:AVERAGE ". "DEF:i={$rrdfile}:insert_failed:AVERAGE ". "DEF:j={$rrdfile}:drop:AVERAGE ". "DEF:k={$rrdfile}:early_drop:AVERAGE ". "DEF:l={$rrdfile}:icmp_error:AVERAGE ". "DEF:m={$rrdfile}:expect_new:AVERAGE ". "DEF:n={$rrdfile}:expect_create:AVERAGE ". "DEF:o={$rrdfile}:expect_delete:AVERAGE ". 'CDEF:ii=i,-1,* '. 'CDEF:jj=j,-1,* '. 'CDEF:kk=k,-1,* '. 'CDEF:ll=l,-1,* '. 'CDEF:mm=m,-1,* '. 'CDEF:nn=n,-1,* '. 'CDEF:oo=o,-1,* '. 'LINE1:a#FF0000:"searched " GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:b#FF00FF:"found " GPRINT:b:LAST:"Current\:%8.0lf" GPRINT:b:AVERAGE:"Average\:%8.0lf" GPRINT:b:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:c#0000FF:"new " GPRINT:c:LAST:"Current\:%8.0lf" GPRINT:c:AVERAGE:"Average\:%8.0lf" GPRINT:c:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:d#007FFF:"invalid " GPRINT:d:LAST:"Current\:%8.0lf" GPRINT:d:AVERAGE:"Average\:%8.0lf" GPRINT:d:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:e#00FFFF:"ignore " GPRINT:e:LAST:"Current\:%8.0lf" GPRINT:e:AVERAGE:"Average\:%8.0lf" GPRINT:e:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:f#00FF00:"delete " GPRINT:f:LAST:"Current\:%8.0lf" GPRINT:f:AVERAGE:"Average\:%8.0lf" GPRINT:f:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:g#FFFF00:"delete_list " GPRINT:g:LAST:"Current\:%8.0lf" GPRINT:g:AVERAGE:"Average\:%8.0lf" GPRINT:g:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:h#FF7F00:"insert " GPRINT:h:LAST:"Current\:%8.0lf" GPRINT:h:AVERAGE:"Average\:%8.0lf" GPRINT:h:MAX:"Maximum\:%8.0lf\n" '. 'HRULE:0#000000:"-\n" '. 'LINE1:ii#FF0000:"insert_failed " GPRINT:i:LAST:"Current\:%8.0lf" GPRINT:i:AVERAGE:"Average\:%8.0lf" GPRINT:i:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:jj#FF00FF:"drop " GPRINT:j:LAST:"Current\:%8.0lf" GPRINT:j:AVERAGE:"Average\:%8.0lf" GPRINT:j:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:kk#0000FF:"early_drop " GPRINT:k:LAST:"Current\:%8.0lf" GPRINT:k:AVERAGE:"Average\:%8.0lf" GPRINT:k:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:ll#007FFF:"icmp_errore " GPRINT:l:LAST:"Current\:%8.0lf" GPRINT:l:AVERAGE:"Average\:%8.0lf" GPRINT:l:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:mm#00FFFF:"expect_new " GPRINT:m:LAST:"Current\:%8.0lf" GPRINT:m:AVERAGE:"Average\:%8.0lf" GPRINT:m:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:nn#00FF00:"expect_create " GPRINT:n:LAST:"Current\:%8.0lf" GPRINT:n:AVERAGE:"Average\:%8.0lf" GPRINT:n:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:oo#FFFF00:"expect_delete " GPRINT:o:LAST:"Current\:%8.0lf" GPRINT:o:AVERAGE:"Average\:%8.0lf" GPRINT:o:MAX:"Maximum\:%8.0lf\n" '; break; case 'load': $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"load\" ". "DEF:a={$rrdfile}:1min:MAX ". "DEF:b={$rrdfile}:5min:MAX ". "DEF:c={$rrdfile}:15min:MAX ". 'CDEF:x=a,b,c,MAX,MAX '. 'AREA:a#EACC00:" 1 Minute Maximum " GPRINT:a:LAST:"Current\:%8.2lf %s\n" '. 'AREA:b#EA8F00:" 5 Minute Maximum " GPRINT:b:LAST:"Current\:%8.2lf %s\n" '. 'AREA:c#FF0000:"15 Minute Maximum " 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 'rtcache': $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"calls\" ". "DEF:a={$rrdfile}:entries:AVERAGE ". "DEF:b={$rrdfile}:gc_total:AVERAGE ". "DEF:c={$rrdfile}:gc_ignored:AVERAGE ". "DEF:d={$rrdfile}:gc_goal_miss:AVERAGE ". "DEF:e={$rrdfile}:gc_dst_overflow:AVERAGE ". 'LINE1:a#FF0000:"entries " GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:b#FF00FF:"gc_total " GPRINT:b:LAST:"Current\:%8.0lf" GPRINT:b:AVERAGE:"Average\:%8.0lf" GPRINT:b:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:c#0000FF:"gc_ignored " GPRINT:c:LAST:"Current\:%8.0lf" GPRINT:c:AVERAGE:"Average\:%8.0lf" GPRINT:c:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:d#007FFF:"gc_goal_miss " GPRINT:d:LAST:"Current\:%8.0lf" GPRINT:d:AVERAGE:"Average\:%8.0lf" GPRINT:d:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:e#00FFFF:"gc_dst_overflow " GPRINT:e:LAST:"Current\:%8.0lf" GPRINT:e:AVERAGE:"Average\:%8.0lf" GPRINT:e:MAX:"Maximum\:%8.0lf\n" '; break; case 'rtstat': $height *= 2; $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"calls\" ". "DEF:a={$rrdfile}:in_hit:AVERAGE ". "DEF:b={$rrdfile}:in_slow_tot:AVERAGE ". "DEF:c={$rrdfile}:in_slow_mc:AVERAGE ". "DEF:d={$rrdfile}:in_no_route:AVERAGE ". "DEF:e={$rrdfile}:in_brd:AVERAGE ". "DEF:f={$rrdfile}:in_martian_dst:AVERAGE ". "DEF:g={$rrdfile}:in_martian_src:AVERAGE ". "DEF:h={$rrdfile}:in_hlist_search:AVERAGE ". "DEF:i={$rrdfile}:out_hit:AVERAGE ". "DEF:j={$rrdfile}:out_slow_tot:AVERAGE ". "DEF:k={$rrdfile}:out_slow_mc:AVERAGE ". "DEF:l={$rrdfile}:out_hlist_search:AVERAGE ". 'CDEF:ii=i,-1,* '. 'CDEF:jj=j,-1,* '. 'CDEF:kk=k,-1,* '. 'CDEF:ll=l,-1,* '. 'LINE1:a#FF0000:"in_hit " GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:b#FF00FF:"in_slow_tot " GPRINT:b:LAST:"Current\:%8.0lf" GPRINT:b:AVERAGE:"Average\:%8.0lf" GPRINT:b:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:c#0000FF:"in_slow_mc " GPRINT:c:LAST:"Current\:%8.0lf" GPRINT:c:AVERAGE:"Average\:%8.0lf" GPRINT:c:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:d#007FFF:"in_no_route " GPRINT:d:LAST:"Current\:%8.0lf" GPRINT:d:AVERAGE:"Average\:%8.0lf" GPRINT:d:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:e#00FFFF:"in_brd " GPRINT:e:LAST:"Current\:%8.0lf" GPRINT:e:AVERAGE:"Average\:%8.0lf" GPRINT:e:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:f#00FF00:"in_martian_dst " GPRINT:f:LAST:"Current\:%8.0lf" GPRINT:f:AVERAGE:"Average\:%8.0lf" GPRINT:f:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:g#FFFF00:"in_martian_src " GPRINT:g:LAST:"Current\:%8.0lf" GPRINT:g:AVERAGE:"Average\:%8.0lf" GPRINT:g:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:h#FF7F00:"in_hlist_search " GPRINT:h:LAST:"Current\:%8.0lf" GPRINT:h:AVERAGE:"Average\:%8.0lf" GPRINT:h:MAX:"Maximum\:%8.0lf\n" '. 'HRULE:0#FF0000:"-\n" '. 'LINE1:ii#FF0000:"out_hit " GPRINT:i:LAST:"Current\:%8.0lf" GPRINT:i:AVERAGE:"Average\:%8.0lf" GPRINT:i:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:jj#FF00FF:"out_slow_tot " GPRINT:j:LAST:"Current\:%8.0lf" GPRINT:j:AVERAGE:"Average\:%8.0lf" GPRINT:j:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:kk#0000FF:"out_slow_mc " GPRINT:k:LAST:"Current\:%8.0lf" GPRINT:k:AVERAGE:"Average\:%8.0lf" GPRINT:k:MAX:"Maximum\:%8.0lf\n" '. 'LINE1:ll#FF7F00:"out_hlist_search " GPRINT:l:LAST:"Current\:%8.0lf" GPRINT:l:AVERAGE:"Average\:%8.0lf" GPRINT:l:MAX:"Maximum\:%8.0lf\n" '; 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,* ". 'HRULE:0#FF0000: '. '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; } ?>