From 0b667ffc9391d84ce4e37485df4bd17f75c7a97e Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 20 Apr 2012 13:00:00 +0000 Subject: [PATCH] more improvements to graphing git-svn-id: http://www.observium.org/svn/observer/trunk@3066 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/graphs/device/bits.inc.php | 6 ++- .../graphs/generic_multi_seperated.inc.php | 45 +++++++++++++++++++ .../generic_multi_simplex_seperated.inc.php | 34 +++++++++++++- 3 files changed, 83 insertions(+), 2 deletions(-) diff --git a/html/includes/graphs/device/bits.inc.php b/html/includes/graphs/device/bits.inc.php index b843760ff9..27c662cf71 100644 --- a/html/includes/graphs/device/bits.inc.php +++ b/html/includes/graphs/device/bits.inc.php @@ -2,6 +2,9 @@ ## Generate a list of ports and then call the multi_bits grapher to generate from the list +$ds_in = "INOCTETS"; +$ds_out = "OUTOCTETS"; + $device = device_by_id_cache($id); foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($id)) as $port) @@ -64,7 +67,8 @@ $colour_line_out = "000099"; $colour_area_in = "91B13C"; $colour_area_out = "8080BD"; +include("includes/graphs/generic_multi_seperated.inc.php"); #include("includes/graphs/generic_multi_bits_separated.inc.php"); -include("includes/graphs/generic_multi_data.inc.php"); +#include("includes/graphs/generic_multi_data.inc.php"); ?> diff --git a/html/includes/graphs/generic_multi_seperated.inc.php b/html/includes/graphs/generic_multi_seperated.inc.php index d25b0f083c..1a450ba832 100644 --- a/html/includes/graphs/generic_multi_seperated.inc.php +++ b/html/includes/graphs/generic_multi_seperated.inc.php @@ -4,6 +4,15 @@ include("includes/graphs/common.inc.php"); $units_descr = substr(str_pad($units_descr, 18),0,18); +if($format == "octets" || $format == "bytes") +{ + $units = "Bps"; + $format = "octets"; +} else { + $units = "bps"; + $format = "bits"; +} + $i = 0; $rrd_options .= " COMMENT:'$units_descr Current Average Maximum\\n'"; if (!$nototal) { $rrd_options .= " COMMENT:' Tot'"; } @@ -25,6 +34,20 @@ foreach ($rrd_list as $rrd) $rrd_options .= " CDEF:outB".$i."=out".$i.",$multiplier,*"; $rrd_options .= " CDEF:outB".$i."_neg=outB".$i.",-1,*"; $rrd_options .= " CDEF:octets".$i."=inB".$i.",outB".$i.",+"; + + if($_GET['previous']) + { + $rrd_options .= " DEF:".$in."octets" . $i . "X=".$rrd['filename'].":".$ds_in.":AVERAGE:start=".$prev_from.":end=".$from; + $rrd_options .= " DEF:".$out."octets" . $i . "X=".$rrd['filename'].":".$ds_out.":AVERAGE:start=".$prev_from.":end=".$from; + $rrd_options .= " SHIFT:".$in."octets" . $i . "X:$period"; + $rrd_options .= " SHIFT:".$out."octets" . $i . "X:$period"; + $in_thingX .= $seperatorX . "inoctets" . $i . "X,UN,0," . "inoctets" . $i . "X,IF"; + $out_thingX .= $seperatorX . "outoctets" . $i . "X,UN,0," . "outoctets" . $i . "X,IF"; + $plusesX .= $plusX; + $seperatorX = ","; + $plusX = ",+"; + } + if (!$args['nototal']) { $rrd_options .= " VDEF:totin".$i."=inB".$i.",TOTAL"; @@ -54,6 +77,28 @@ foreach ($rrd_list as $rrd) $i++; $iter++; } + if($_GET['previous'] == "yes") + { + $rrd_options .= " CDEF:".$in."octetsX=" . $in_thingX . $plusesX; + $rrd_options .= " CDEF:".$out."octetsX=" . $out_thingX . $plusesX; + $rrd_options .= " CDEF:doutoctetsX=outoctetsX,-1,*"; + $rrd_options .= " CDEF:inbitsX=inoctetsX,8,*"; + $rrd_options .= " CDEF:outbitsX=outoctetsX,8,*"; + $rrd_options .= " CDEF:doutbitsX=doutoctetsX,8,*"; + $rrd_options .= " VDEF:95thinX=inbitsX,95,PERCENT"; + $rrd_options .= " VDEF:95thoutX=outbitsX,95,PERCENT"; + $rrd_options .= " VDEF:d95thoutX=doutbitsX,5,PERCENT"; + } + + if($_GET['previous'] == "yes") + { + $rrd_options .= " AREA:in".$format."X#99999999:"; + $rrd_options .= " AREA:dout".$format."X#99999999:"; + $rrd_options .= " LINE1.25:in".$format."X#666666:"; + $rrd_options .= " LINE1.25:dout".$format."X#666666:"; + } + + $rrd_options .= $rrd_optionsb; $rrd_options .= " HRULE:0#999999"; diff --git a/html/includes/graphs/generic_multi_simplex_seperated.inc.php b/html/includes/graphs/generic_multi_simplex_seperated.inc.php index e3d4d158f2..04b5359159 100644 --- a/html/includes/graphs/generic_multi_simplex_seperated.inc.php +++ b/html/includes/graphs/generic_multi_simplex_seperated.inc.php @@ -52,6 +52,16 @@ foreach ($rrd_list as $i => $rrd) $rrd_options .= " DEF:".$rrd['ds'].$i."max=".$rrd['filename'].":".$rrd['ds'].":MAX "; } + if($_GET['previous']) + { + $rrd_options .= " DEF:".$i . "X=".$rrd['filename'].":".$rrd['ds'].":AVERAGE:start=".$prev_from.":end=".$from; + $rrd_options .= " SHIFT:".$i . "X:$period"; + $thingX .= $seperatorX . $i . "X,UN,0," . $i . "X,IF"; + $plusesX .= $plusX; + $seperatorX = ","; + $plusX = ",+"; + } + ## Suppress totalling? if (!$nototal) { @@ -60,7 +70,6 @@ foreach ($rrd_list as $i => $rrd) ## This this not the first entry? if ($i) { $stack="STACK"; } - # if we've been passed a multiplier we must make a CDEF based on it! $g_defname = $rrd['ds']; if (is_numeric($multiplier)) @@ -79,6 +88,8 @@ foreach ($rrd_list as $i => $rrd) $rrd_options .= " CDEF:" . $g_defname . $i . "max=" . $rrd['ds'] . $i . "max," . $divider . ",/"; } + + ## Are our text values related to te multiplier/divisor or not? if (isset($text_orig) && $text_orig) { @@ -97,4 +108,25 @@ foreach ($rrd_list as $i => $rrd) $rrd_options .= " COMMENT:'\\n'"; } + if($_GET['previous'] == "yes") + { + if (is_numeric($multiplier)) + { + $rrd_options .= " CDEF:X=" . $thingX . $plusesX.",".$multiplier. ",*"; + } elseif (is_numeric($divider)) + { + $rrd_options .= " CDEF:X=" . $thingX . $plusesX.",".$divider. ",/"; + } else + { + $rrd_options .= " CDEF:X=" . $thingX . $plusesX; + } + + $rrd_options .= " AREA:X#99999999:"; + $rrd_options .= " LINE1.25:X#666666:"; + + + } + + + ?>