fix a bunch of graph definitions to work with pipe. replace escaping with quoting.

git-svn-id: http://www.observium.org/svn/observer/trunk@2494 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-09-18 18:22:07 +00:00
parent fa8f834a89
commit 02024f510a
8 changed files with 119 additions and 114 deletions

View File

@@ -1,9 +1,11 @@
<?php
function rrdtool_graph($rrdfile, $options)
function rrdtool_graph($graph_file, $options)
{
global $config;
global $config, $debug;
if($debug) { echo("$options"); }
if ($config['rrdcached'])
{
@@ -29,7 +31,9 @@ function rrdtool_graph($rrdfile, $options)
// 1 => readable handle connected to child stdout
// Any error output will be appended to /tmp/error-output.txt
fwrite($pipes[0], "graph $rrdfile $options");
# echo (strlen("graph $graph_file $options"));
fwrite($pipes[0], "graph $graph_file $options");
fclose($pipes[0]);
fclose($pipes[1]);

View File

@@ -9,12 +9,12 @@ include("includes/graphs/common.inc.php");
$database = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_processes.rrd";
$rrd_options .= " DEF:procs=$database:procs:AVERAGE";
$rrd_options .= " COMMENT:Processes\ \ \ \ Cur\ \ \ \ \ Ave\ \ \ \ \ \ Min\ \ \ \ \ Max\\\\n";
$rrd_options .= " COMMENT:'Processes Cur Ave Min Max\\n'";
$rrd_options .= " AREA:procs#CDEB8B:";
$rrd_options .= " LINE1.25:procs#008C00:\ ";
$rrd_options .= " GPRINT:procs:LAST:\ \ \ \ %6.2lf";
$rrd_options .= " LINE1.25:procs#008C00:' '";
$rrd_options .= " GPRINT:procs:LAST:' %6.2lf'";
$rrd_options .= " GPRINT:procs:AVERAGE:%6.2lf";
$rrd_options .= " GPRINT:procs:MIN:%6.2lf";
$rrd_options .= " GPRINT:procs:MAX:%6.2lf\\\\n";
$rrd_options .= " GPRINT:procs:MAX:'%6.2lf\\n'";
?>
?>

View File

@@ -10,13 +10,13 @@ $database = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_users.rrd";
$rrd_options .= " DEF:users=$database:users:AVERAGE";
$rrd_options .= " DEF:users_max=$database:users:MAX";
$rrd_options .= " COMMENT:Users\ \ \ \ \ \ Cur\ \ \ \ \ Ave\ \ \ \ \ \ Min\ \ \ \ \ Max\\\\n";
$rrd_options .= " COMMENT:'Users Cur Ave Min Max\\n'";
$rrd_options .= " AREA:users_max#defc9c:";
$rrd_options .= " AREA:users#CDEB8B:";
$rrd_options .= " LINE1.25:users#008C00:\ ";
$rrd_options .= " GPRINT:users:LAST:\ \ \ \ %6.2lf";
$rrd_options .= " LINE1.25:users#008C00: ";
$rrd_options .= " GPRINT:users:LAST:' %6.2lf'";
$rrd_options .= " GPRINT:users:AVERAGE:%6.2lf";
$rrd_options .= " GPRINT:users:MIN:%6.2lf";
$rrd_options .= " GPRINT:users_max:MAX:%6.2lf\\\\n";
$rrd_options .= " GPRINT:users_max:MAX:'%6.2lf\\n'";
?>
?>

View File

@@ -11,22 +11,22 @@ $rrd_options .= " CDEF:user_perc=user,total,/,100,*";
$rrd_options .= " CDEF:nice_perc=nice,total,/,100,*";
$rrd_options .= " CDEF:system_perc=system,total,/,100,*";
$rrd_options .= " CDEF:idle_perc=idle,total,/,100,*";
$rrd_options .= " COMMENT:Usage\ \ \ \ \ \ \ Current\ \ \ \ \ Average\ \ \ \ Maximum\\\\n";
$rrd_options .= " COMMENT:'Usage Current Average Maximum\\n'";
$rrd_options .= " AREA:user_perc#c02020:user";
$rrd_options .= " GPRINT:user_perc:LAST:\ \ \ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:user_perc:AVERAGE:\ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:user_perc:MAX:\ \ \ %5.2lf%%\\\\n";
$rrd_options .= " GPRINT:user_perc:LAST:' %5.2lf%%'";
$rrd_options .= " GPRINT:user_perc:AVERAGE:' %5.2lf%%'";
$rrd_options .= " GPRINT:user_perc:MAX:' %5.2lf%%\\n'";
$rrd_options .= " AREA:nice_perc#008f00:nice:STACK";
$rrd_options .= " GPRINT:nice_perc:LAST:\ \ \ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:nice_perc:AVERAGE:\ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:nice_perc:MAX:\ \ \ %5.2lf%%\\\\n";
$rrd_options .= " GPRINT:nice_perc:LAST:' %5.2lf%%'";
$rrd_options .= " GPRINT:nice_perc:AVERAGE:' %5.2lf%%'";
$rrd_options .= " GPRINT:nice_perc:MAX:' %5.2lf%%\\n'";
$rrd_options .= " AREA:system_perc#ea8f00:system:STACK";
$rrd_options .= " GPRINT:system_perc:LAST:\ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:system_perc:AVERAGE:\ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:system_perc:MAX:\ \ \ %5.2lf%%\\\\n";
$rrd_options .= " GPRINT:system_perc:LAST:' %5.2lf%%'";
$rrd_options .= " GPRINT:system_perc:AVERAGE:' %5.2lf%%'";
$rrd_options .= " GPRINT:system_perc:MAX:' %5.2lf%%\\n'";
$rrd_options .= " AREA:idle_perc#f5f5e5:idle:STACK";
$rrd_options .= " GPRINT:idle_perc:LAST:\ \ \ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:idle_perc:AVERAGE:\ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:idle_perc:MAX:\ \ \ %5.2lf%%\\\\n";
$rrd_options .= " GPRINT:idle_perc:LAST:' %5.2lf%%'";
$rrd_options .= " GPRINT:idle_perc:AVERAGE:' %5.2lf%%'";
$rrd_options .= " GPRINT:idle_perc:MAX:' %5.2lf%%\\n'";
?>
?>

View File

@@ -14,19 +14,19 @@ $rrd_options .= " CDEF:a=1min,100,/";
$rrd_options .= " CDEF:b=5min,100,/";
$rrd_options .= " CDEF:c=15min,100,/";
$rrd_options .= " CDEF:cdefd=a,b,c,+,+";
$rrd_options .= " COMMENT:Load\ Average\ \ Current\ \ \ \ Average\ \ \ \ Maximum\\\\n";
$rrd_options .= " AREA:a#ffeeaa:1\ Min:";
$rrd_options .= " COMMENT:'Load Average Current Average Maximum\\n'";
$rrd_options .= " AREA:a#ffeeaa:'1 Min':";
$rrd_options .= " LINE1:a#c5aa00:";
$rrd_options .= " GPRINT:a:LAST:\ \ \ \ %7.2lf";
$rrd_options .= " GPRINT:a:AVERAGE:\ \ %7.2lf";
$rrd_options .= " GPRINT:a:MAX:\ \ %7.2lf\\\\n";
$rrd_options .= " LINE1.25:b#ea8f00:5\ Min:";
$rrd_options .= " GPRINT:b:LAST:\ \ \ \ %7.2lf";
$rrd_options .= " GPRINT:b:AVERAGE:\ \ %7.2lf";
$rrd_options .= " GPRINT:b:MAX:\ \ %7.2lf\\\\n";
$rrd_options .= " LINE1.25:c#cc0000:15\ Min";
$rrd_options .= " GPRINT:c:LAST:\ \ \ %7.2lf";
$rrd_options .= " GPRINT:c:AVERAGE:\ \ %7.2lf";
$rrd_options .= " GPRINT:c:MAX:\ \ %7.2lf\\\\n";
$rrd_options .= " GPRINT:a:LAST:' %7.2lf'";
$rrd_options .= " GPRINT:a:AVERAGE:' %7.2lf'";
$rrd_options .= " GPRINT:a:MAX:' %7.2lf\\n'";
$rrd_options .= " LINE1.25:b#ea8f00:'5 Min':";
$rrd_options .= " GPRINT:b:LAST:' %7.2lf'";
$rrd_options .= " GPRINT:b:AVERAGE:' %7.2lf'";
$rrd_options .= " GPRINT:b:MAX:' %7.2lf\\n'";
$rrd_options .= " LINE1.25:c#cc0000:'15 Min'";
$rrd_options .= " GPRINT:c:LAST:' %7.2lf'";
$rrd_options .= " GPRINT:c:AVERAGE:' %7.2lf'";
$rrd_options .= " GPRINT:c:MAX:' %7.2lf\\n'";
?>
?>

View File

@@ -5,61 +5,61 @@ $device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ucd_mem.rrd";
$rrd_options .= " -b 1024";
$rrd_options .= " '-b 1024'";
$rrd_options .= " DEF:atotalswap=$rrd_filename:totalswap:AVERAGE";
$rrd_options .= " DEF:aavailswap=$rrd_filename:availswap:AVERAGE";
$rrd_options .= " DEF:atotalreal=$rrd_filename:totalreal:AVERAGE";
$rrd_options .= " DEF:aavailreal=$rrd_filename:availreal:AVERAGE";
$rrd_options .= " DEF:atotalfree=$rrd_filename:totalfree:AVERAGE";
$rrd_options .= " DEF:ashared=$rrd_filename:shared:AVERAGE";
$rrd_options .= " DEF:abuffered=$rrd_filename:buffered:AVERAGE";
$rrd_options .= " DEF:acached=$rrd_filename:cached:AVERAGE";
$rrd_options .= " CDEF:totalswap=atotalswap,1024,*";
$rrd_options .= " CDEF:availswap=aavailswap,1024,*";
$rrd_options .= " CDEF:totalreal=atotalreal,1024,*";
$rrd_options .= " CDEF:availreal=aavailreal,1024,*";
$rrd_options .= " CDEF:totalfree=atotalfree,1024,*";
$rrd_options .= " CDEF:shared=ashared,1024,*";
$rrd_options .= " CDEF:buffered=abuffered,1024,*";
$rrd_options .= " CDEF:cached=acached,1024,*";
$rrd_options .= " CDEF:usedreal=totalreal,availreal,-";
$rrd_options .= " CDEF:usedswap=totalswap,availswap,-";
$rrd_options .= " CDEF:cusedswap=usedswap,-1,*";
$rrd_options .= " CDEF:cdeftot=availreal,shared,buffered,usedreal,cached,usedswap,+,+,+,+,+";
$rrd_options .= " COMMENT:'Bytes Current Average Maximum\\n'";
$rrd_options .= " LINE1:usedreal#d0b080:";
$rrd_options .= " AREA:usedreal#f0e0a0:used";
$rrd_options .= " GPRINT:usedreal:LAST:\ \ \ %7.2lf%sB";
$rrd_options .= " GPRINT:usedreal:AVERAGE:%7.2lf%sB";
$rrd_options .= " GPRINT:usedreal:MAX:%7.2lf%sB\\\\n";
$rrd_options .= " STACK:availreal#e5e5e5:free";
$rrd_options .= " GPRINT:availreal:LAST:\ \ \ %7.2lf%sB";
$rrd_options .= " GPRINT:availreal:AVERAGE:%7.2lf%sB";
$rrd_options .= " GPRINT:availreal:MAX:%7.2lf%sB\\\\n";
$rrd_options .= " LINE1:usedreal#d0b080:";
$rrd_options .= " AREA:shared#afeced::";
$rrd_options .= " AREA:buffered#cc0000::STACK";
$rrd_options .= " AREA:cached#ffaa66::STACK";
$rrd_options .= " LINE1.25:shared#008fea:shared";
$rrd_options .= " GPRINT:shared:LAST:\ %7.2lf%sB";
$rrd_options .= " GPRINT:shared:AVERAGE:%7.2lf%sB";
$rrd_options .= " GPRINT:shared:MAX:%7.2lf%sB\\\\n";
$rrd_options .= " LINE1.25:buffered#ff1a00:buffers:STACK";
$rrd_options .= " GPRINT:buffered:LAST:%7.2lf%sB";
$rrd_options .= " GPRINT:buffered:AVERAGE:%7.2lf%sB";
$rrd_options .= " GPRINT:buffered:MAX:%7.2lf%sB\\\\n";
$rrd_options .= " LINE1.25:cached#ea8f00:cached:STACK";
$rrd_options .= " GPRINT:cached:LAST:\ %7.2lf%sB";
$rrd_options .= " GPRINT:cached:AVERAGE:%7.2lf%sB";
$rrd_options .= " GPRINT:cached:MAX:%7.2lf%sB\\\\n";
$rrd_options .= " LINE1:totalreal#050505:";
$rrd_options .= " AREA:cusedswap#C3D9FF:swap";
$rrd_options .= " LINE1.25:cusedswap#356AA0:";
$rrd_options .= " GPRINT:usedswap:LAST:\ \ \ %7.2lf%sB";
$rrd_options .= " GPRINT:usedswap:AVERAGE:%7.2lf%sB";
$rrd_options .= " GPRINT:usedswap:MAX:%7.2lf%sB\\\\n";
$rrd_options .= " LINE1:totalreal#050505:total";
$rrd_options .= " GPRINT:totalreal:AVERAGE:\ \ %7.2lf%sB";
$rrd_options .= " 'DEF:atotalswap=$rrd_filename:totalswap:AVERAGE'";
$rrd_options .= " 'DEF:aavailswap=$rrd_filename:availswap:AVERAGE'";
$rrd_options .= " 'DEF:atotalreal=$rrd_filename:totalreal:AVERAGE'";
$rrd_options .= " 'DEF:aavailreal=$rrd_filename:availreal:AVERAGE'";
$rrd_options .= " 'DEF:atotalfree=$rrd_filename:totalfree:AVERAGE'";
$rrd_options .= " 'DEF:ashared=$rrd_filename:shared:AVERAGE'";
$rrd_options .= " 'DEF:abuffered=$rrd_filename:buffered:AVERAGE'";
$rrd_options .= " 'DEF:acached=$rrd_filename:cached:AVERAGE'";
$rrd_options .= " 'CDEF:totalswap=atotalswap,1024,*'";
$rrd_options .= " 'CDEF:availswap=aavailswap,1024,*'";
$rrd_options .= " 'CDEF:totalreal=atotalreal,1024,*'";
$rrd_options .= " 'CDEF:availreal=aavailreal,1024,*'";
$rrd_options .= " 'CDEF:totalfree=atotalfree,1024,*'";
$rrd_options .= " 'CDEF:shared=ashared,1024,*'";
$rrd_options .= " 'CDEF:buffered=abuffered,1024,*'";
$rrd_options .= " 'CDEF:cached=acached,1024,*'";
$rrd_options .= " 'CDEF:usedreal=totalreal,availreal,-'";
$rrd_options .= " 'CDEF:usedswap=totalswap,availswap,-'";
$rrd_options .= " 'CDEF:cusedswap=usedswap,-1,*'";
$rrd_options .= " 'CDEF:cdeftot=availreal,shared,buffered,usedreal,cached,usedswap,+,+,+,+,+'";
$rrd_options .= " 'COMMENT:Bytes Current Average Maximum\\n'";
$rrd_options .= " 'LINE1:usedreal#d0b080:'";
$rrd_options .= " 'AREA:usedreal#f0e0a0:used'";
$rrd_options .= " 'GPRINT:usedreal:LAST: %7.2lf%sB'";
$rrd_options .= " 'GPRINT:usedreal:AVERAGE:%7.2lf%sB'";
$rrd_options .= " 'GPRINT:usedreal:MAX:%7.2lf%sB\\n'";
$rrd_options .= " 'STACK:availreal#e5e5e5:free'";
$rrd_options .= " 'GPRINT:availreal:LAST: %7.2lf%sB'";
$rrd_options .= " 'GPRINT:availreal:AVERAGE:%7.2lf%sB'";
$rrd_options .= " 'GPRINT:availreal:MAX:%7.2lf%sB\\n'";
$rrd_options .= " 'LINE1:usedreal#d0b080:'";
$rrd_options .= " 'AREA:shared#afeced::'";
$rrd_options .= " 'AREA:buffered#cc0000::STACK'";
$rrd_options .= " 'AREA:cached#ffaa66::STACK'";
$rrd_options .= " 'LINE1.25:shared#008fea:shared'";
$rrd_options .= " 'GPRINT:shared:LAST: %7.2lf%sB'";
$rrd_options .= " 'GPRINT:shared:AVERAGE:%7.2lf%sB'";
$rrd_options .= " 'GPRINT:shared:MAX:%7.2lf%sB\\n'";
$rrd_options .= " 'LINE1.25:buffered#ff1a00:buffers:STACK'";
$rrd_options .= " 'GPRINT:buffered:LAST:%7.2lf%sB'";
$rrd_options .= " 'GPRINT:buffered:AVERAGE:%7.2lf%sB'";
$rrd_options .= " 'GPRINT:buffered:MAX:%7.2lf%sB\\n'";
$rrd_options .= " 'LINE1.25:cached#ea8f00:cached:STACK'";
$rrd_options .= " 'GPRINT:cached:LAST: %7.2lf%sB'";
$rrd_options .= " 'GPRINT:cached:AVERAGE:%7.2lf%sB'";
$rrd_options .= " 'GPRINT:cached:MAX:%7.2lf%sB\\n'";
$rrd_options .= " 'LINE1:totalreal#050505:'";
$rrd_options .= " 'AREA:cusedswap#C3D9FF:swap'";
$rrd_options .= " 'LINE1.25:cusedswap#356AA0:'";
$rrd_options .= " 'GPRINT:usedswap:LAST: %7.2lf%sB'";
$rrd_options .= " 'GPRINT:usedswap:AVERAGE:%7.2lf%sB'";
$rrd_options .= " 'GPRINT:usedswap:MAX:%7.2lf%sB\\n'";
$rrd_options .= " 'LINE1:totalreal#050505:total'";
$rrd_options .= " 'GPRINT:totalreal:AVERAGE: %7.2lf%sB'";
?>
?>

View File

@@ -7,12 +7,12 @@ $device = device_by_id_cache($id);
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/uptime.rrd";
$rrd_options .= " DEF:uptime=$rrd_filename:uptime:AVERAGE";
$rrd_options .= " DEF:uptime=".$rrd_filename.":uptime:AVERAGE";
$rrd_options .= " CDEF:cuptime=uptime,86400,/";
$rrd_options .= " COMMENT:Days\ \ \ \ \ \ Current\ \ Minimum\ \ Maximum\ \ Average\\\\n";
$rrd_options .= " 'COMMENT:Days Current Minimum Maximum Average\\n'";
$rrd_options .= " AREA:cuptime#EEEEEE:Uptime";
$rrd_options .= " LINE1.25:cuptime#36393D:";
$rrd_options .= " GPRINT:cuptime:LAST:%6.2lf\ GPRINT:cuptime:AVERAGE:%6.2lf\ ";
$rrd_options .= " GPRINT:cuptime:MAX:%6.2lf\ GPRINT:cuptime:AVERAGE:%6.2lf\\\\n";
$rrd_options .= " GPRINT:cuptime:LAST:%6.2lf GPRINT:cuptime:AVERAGE:%6.2lf";
$rrd_options .= " GPRINT:cuptime:MAX:%6.2lf 'GPRINT:cuptime:AVERAGE:%6.2lf\\n'";
?>
?>

View File

@@ -1,6 +1,6 @@
<?php
### Sections are printed in the order they exist in $config['graph_tabs']
### Sections are printed in the order they exist in $config['graph_sections']
### Graphs are printed in the order they exist in $config['graph_types']
$link_array = array('page' => 'device',
@@ -11,7 +11,7 @@ $bg="#ffffff";
echo('<div style="clear: both;">');
print_optionbar_start('', '');
print_optionbar_start();
echo("<span style='font-weight: bold;'>Graphs</span> &#187; ");
@@ -19,24 +19,25 @@ $sep = "";
foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ?", array($device['device_id'])) as $graph)
{
$tab = $config['graph_types']['device'][$graph['graph']]['tab'];
$graph_enable[$tab][$graph['graph']] = $graph['graph'];
$section = $config['graph_types']['device'][$graph['graph']]['section'];
$graph_enable[$section][$graph['graph']] = $graph['graph'];
}
foreach ($config['graph_tabs'] as $tab)
foreach ($config['graph_sections'] as $section)
{
if (isset($graph_enable) && is_array($graph_enable[$tab]))
if (isset($graph_enable) && is_array($graph_enable[$section]))
{
$type = strtolower($tab);
if (!$_GET['optc']) { $_GET['optc'] = $type; }
$type = strtolower($section);
if (!$vars['group']) { $vars['group'] = $type; }
echo($sep);
if ($_GET['optc'] == $type)
if ($vars['group'] == $type)
{
echo('<span class="pagemenu-selected">');
}
echo("<a href='device/".$device['device_id']."/graphs/" . $type . ($_GET['optd'] ? "/" . $_GET['optd'] : ''). "/'> " . ucfirst($type) ."</a>");
if ($_GET['optc'] == $type)
echo(generate_link(ucfirst($type),$link_array,array('group'=>$type)));
if ($vars['group'] == $type)
{
echo("</span>");
}
@@ -47,7 +48,7 @@ foreach ($config['graph_tabs'] as $tab)
unset ($sep);
print_optionbar_end();
$graph_enable = $graph_enable[$_GET['optc']];
$graph_enable = $graph_enable[$vars['group']];
foreach ($config['graph_types']['device'] as $graph => $entry)
{