From c3eae27d25cfbbade4a6c1a7df29bf4e77c877ee Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Mon, 2 Aug 2010 22:50:42 +0000 Subject: [PATCH] ok not all graphs, but a few more (atleast cpu, mem and bits for device overlibs) git-svn-id: http://www.observium.org/svn/observer/trunk@1630 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/graphs/device/mempools.inc.php | 19 ++++++++------- .../graphs/generic_multi_bits.inc.php | 23 +++++++++++-------- html/includes/graphs/graph.inc.php | 5 ++-- html/includes/graphs/port/upkts.inc.php | 2 +- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/html/includes/graphs/device/mempools.inc.php b/html/includes/graphs/device/mempools.inc.php index 2ca7b3c74a..d444758200 100644 --- a/html/includes/graphs/device/mempools.inc.php +++ b/html/includes/graphs/device/mempools.inc.php @@ -15,14 +15,17 @@ while($mempool = mysql_fetch_array($query)) { } elseif($iter=="7") {$colour="FF0084"; unset($iter); } $descr = substr(str_pad(short_hrDeviceDescr($mempool['mempool_descr']), 28),0,28); $descr = str_replace(":", "\:", $descr); - $rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("mempool-".$mempool['mempool_type']."-".$mempool['mempool_index'].".rrd"); - $rrd_options .= " DEF:mempoolfree$i=$rrd:free:AVERAGE "; - $rrd_options .= " DEF:mempoolused$i=$rrd:used:AVERAGE "; - $rrd_options .= " CDEF:mempooltotal$i=mempoolused$i,mempoolused$i,mempoolfree$i,+,/,100,* "; - $rrd_options .= " LINE1:mempooltotal$i#" . $colour . ":'" . $descr . "' "; - $rrd_options .= " GPRINT:mempooltotal$i:LAST:%3.0lf"; - $rrd_options .= " GPRINT:mempooltotal$i:MAX:%3.0lf\\\l "; - $iter++; $i++; + $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("mempool-".$mempool['mempool_type']."-".$mempool['mempool_index'].".rrd"); + if(is_file($rrd_filename)) + { + $rrd_options .= " DEF:mempoolfree$i=$rrd_filename:free:AVERAGE "; + $rrd_options .= " DEF:mempoolused$i=$rrd_filename:used:AVERAGE "; + $rrd_options .= " CDEF:mempooltotal$i=mempoolused$i,mempoolused$i,mempoolfree$i,+,/,100,* "; + $rrd_options .= " LINE1:mempooltotal$i#" . $colour . ":'" . $descr . "' "; + $rrd_options .= " GPRINT:mempooltotal$i:LAST:%3.0lf"; + $rrd_options .= " GPRINT:mempooltotal$i:MAX:%3.0lf\\\l "; + $iter++; $i++; + } } $rrd_options .= " HRULE:0#999999"; diff --git a/html/includes/graphs/generic_multi_bits.inc.php b/html/includes/graphs/generic_multi_bits.inc.php index 7805988c25..120564111f 100644 --- a/html/includes/graphs/generic_multi_bits.inc.php +++ b/html/includes/graphs/generic_multi_bits.inc.php @@ -7,17 +7,19 @@ include("includes/graphs/common.inc.php"); $i=0; foreach($rrd_filenames as $rrd_filename) { - $rrd_options .= " DEF:inoctets" . $i . "=".$rrd_filename.":".$rra_in.":AVERAGE"; - $rrd_options .= " DEF:outoctets" . $i . "=".$rrd_filename.":".$rra_out.":AVERAGE"; - $in_thing .= $seperator . "inoctets" . $i . ",UN,0," . "inoctets" . $i . ",IF"; - $out_thing .= $seperator . "outoctets" . $i . ",UN,0," . "outoctets" . $i . ",IF"; - $pluses .= $plus; - $seperator = ","; - $plus = ",+"; - $i++; + $rrd_options .= " DEF:inoctets" . $i . "=".$rrd_filename.":".$rra_in.":AVERAGE"; + $rrd_options .= " DEF:outoctets" . $i . "=".$rrd_filename.":".$rra_out.":AVERAGE"; + $in_thing .= $seperator . "inoctets" . $i . ",UN,0," . "inoctets" . $i . ",IF"; + $out_thing .= $seperator . "outoctets" . $i . ",UN,0," . "outoctets" . $i . ",IF"; + $pluses .= $plus; + $seperator = ","; + $plus = ",+"; + $i++; } -if($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; } +if($i) +{ + if($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; } $rrd_options .= " CDEF:".$in."octets=" . $in_thing . $pluses; $rrd_options .= " CDEF:".$out."octets=" . $out_thing . $pluses; $rrd_options .= " CDEF:doutoctets=outoctets,-1,*"; @@ -42,7 +44,8 @@ if($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; } $rrd_options .= " GPRINT:outbits:AVERAGE:%6.2lf%s"; $rrd_options .= " GPRINT:outbits:MAX:%6.2lf%s\\\l"; } -$rrd_options .= " HRULE:0#999999"; +} +#$rrd_options .= " HRULE:0#999999"; ?> diff --git a/html/includes/graphs/graph.inc.php b/html/includes/graphs/graph.inc.php index cc0d3a88ec..9f90c7ab4b 100644 --- a/html/includes/graphs/graph.inc.php +++ b/html/includes/graphs/graph.inc.php @@ -81,7 +81,7 @@ function graph_error ($string) { global $width, $height; header('Content-type: image/png'); - if($height > "99") { $width +=79; } + if($height > "99") { $width +=76; } $im = imagecreate($width, $height); $orange = imagecolorallocate($im, 255, 225, 225); $px = (imagesx($im) - 7.5 * strlen($string)) / 2; @@ -91,7 +91,6 @@ function graph_error ($string) exit(); } - if(!$auth) { if($width < 200) @@ -101,6 +100,7 @@ if(!$auth) graph_error("No Authorisation"); } } else { + $rrd_options .= " HRULE:0#999999"; if($no_file) { if($width < 200) @@ -113,7 +113,6 @@ if(!$auth) if($rrd_options) { if($config['rrdcached']) { $rrd_switches = " --daemon ".$config['rrdcached'] . " "; } - $rrd_options .= " HRULE:0#999999"; $rrd_cmd = $config['rrdtool'] . " graph $graphfile $rrd_options" . $rrd_switches; $woo = shell_exec($rrd_cmd); if($_GET['debug']) { echo("
".$rrd_cmd."
"); } diff --git a/html/includes/graphs/port/upkts.inc.php b/html/includes/graphs/port/upkts.inc.php index 89539ea01b..330000b5b9 100644 --- a/html/includes/graphs/port/upkts.inc.php +++ b/html/includes/graphs/port/upkts.inc.php @@ -16,6 +16,6 @@ $colour_area_out_max = "FFefaa"; $graph_max = 1; $unit_text = "Packets"; -include("includes/graphs/generic_duplex.inc.php"); +#include("includes/graphs/generic_duplex.inc.php"); ?>