more improvements to graphing

git-svn-id: http://www.observium.org/svn/observer/trunk@3066 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2012-04-20 13:00:00 +00:00
parent a3b2db29b4
commit 0b667ffc93
3 changed files with 83 additions and 2 deletions

View File

@@ -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");
?>

View File

@@ -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";

View File

@@ -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:";
}
?>