Files
librenms-librenms/html/includes/graphs/generic_multi_simplex_seperated.inc.php
T

128 lines
4.0 KiB
PHP
Raw Normal View History

2009-10-28 13:52:39 +00:00
<?php
2011-03-17 10:57:51 +00:00
include("includes/graphs/common.inc.php");
2009-10-28 13:52:39 +00:00
2011-10-25 09:47:45 +00:00
if($width > "500")
{
2012-05-25 12:24:34 +00:00
$descr_len = 24; // FIXME may even be more imo?
2011-10-25 09:47:45 +00:00
} else {
2012-05-23 10:18:14 +00:00
$descr_len = 12;
2011-10-25 09:47:45 +00:00
$descr_len += round(($width - 250) / 8);
}
2011-09-26 16:33:13 +00:00
if ($nototal) { $descrlen += "2"; $unitlen += "2";}
$unit_text = str_pad(truncate($unit_text,$unitlen),$unitlen);
2011-10-25 09:47:45 +00:00
if($width > "500")
{
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)."Now Min Max Avg\l'";
if (!$nototal) { $rrd_options .= " COMMENT:'Total '"; }
$rrd_options .= " COMMENT:'\l'";
} else {
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, $descr_len+5),0,$descr_len+5)."Now Min Max Avg\l'";
}
$unitlen = "10";
if ($nototal) { $descrlen += "2"; $unitlen += "2";}
$unit_text = str_pad(truncate($unit_text,$unitlen),$unitlen);
2011-03-17 10:57:51 +00:00
$colour_iter=0;
foreach ($rrd_list as $i => $rrd)
2011-03-17 10:57:51 +00:00
{
2011-09-22 15:05:11 +00:00
if ($rrd['colour'])
{
$colour = $rrd['colour'];
} else {
if (!$config['graph_colours'][$colours][$colour_iter]) { $colour_iter = 0; }
$colour = $config['graph_colours'][$colours][$colour_iter];
$colour_iter++;
}
2012-05-23 10:18:14 +00:00
$descr = rrdtool_escape($rrd['descr'], $descr_len);
2011-10-25 09:47:45 +00:00
$rrd_options .= " DEF:".$rrd['ds'].$i."=".$rrd['filename'].":".$rrd['ds'].":AVERAGE ";
2011-09-30 13:09:14 +00:00
2011-10-01 10:10:02 +00:00
if ($simple_rrd)
{
$rrd_options .= " CDEF:".$rrd['ds'].$i."min=".$rrd['ds'].$i." ";
$rrd_options .= " CDEF:".$rrd['ds'].$i."max=".$rrd['ds'].$i." ";
} else {
$rrd_options .= " DEF:".$rrd['ds'].$i."min=".$rrd['filename'].":".$rrd['ds'].":MIN ";
$rrd_options .= " DEF:".$rrd['ds'].$i."max=".$rrd['filename'].":".$rrd['ds'].":MAX ";
}
2012-04-21 00:36:55 +00:00
if ($_GET['previous'])
2012-04-20 13:00:00 +00:00
{
$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 = ",+";
}
2012-05-25 12:24:34 +00:00
// Suppress totalling?
if (!$nototal)
2011-03-17 10:57:51 +00:00
{
$rrd_options .= " VDEF:tot".$rrd['ds'].$i."=".$rrd['ds'].$i.",TOTAL";
2009-10-28 13:52:39 +00:00
}
2012-05-25 12:24:34 +00:00
// This this not the first entry?
2011-03-17 10:57:51 +00:00
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))
{
$g_defname = $rrd['ds'] . "_cdef";
$rrd_options .= " CDEF:" . $g_defname . $i . "=" . $rrd['ds'] . $i . "," . $multiplier . ",*";
$rrd_options .= " CDEF:" . $g_defname . $i . "min=" . $rrd['ds'] . $i . "min," . $multiplier . ",*";
$rrd_options .= " CDEF:" . $g_defname . $i . "max=" . $rrd['ds'] . $i . "max," . $multiplier . ",*";
2011-09-20 09:55:11 +00:00
2012-05-25 12:24:34 +00:00
// If we've been passed a divider (divisor!) we make a CDEF for it.
} elseif (is_numeric($divider))
{
$g_defname = $rrd['ds'] . "_cdef";
$rrd_options .= " CDEF:" . $g_defname . $i . "=" . $rrd['ds'] . $i . "," . $divider . ",/";
$rrd_options .= " CDEF:" . $g_defname . $i . "min=" . $rrd['ds'] . $i . "min," . $divider . ",/";
$rrd_options .= " CDEF:" . $g_defname . $i . "max=" . $rrd['ds'] . $i . "max," . $divider . ",/";
}
2011-03-17 10:57:51 +00:00
2012-05-25 12:24:34 +00:00
// Are our text values related to te multiplier/divisor or not?
2011-09-20 14:37:54 +00:00
if (isset($text_orig) && $text_orig)
{
$t_defname = $rrd['ds'];
} else {
$t_defname = $g_defname;
}
2011-10-25 09:47:45 +00:00
$rrd_options .= " AREA:".$g_defname.$i."#".$colour.":'".$descr."':$stack";
$rrd_options .= " GPRINT:".$t_defname.$i.":LAST:%5.2lf%s GPRINT:".$t_defname.$i."min:MIN:%5.2lf%s";
$rrd_options .= " GPRINT:".$t_defname.$i."max:MAX:%5.2lf%s GPRINT:".$t_defname.$i.":AVERAGE:'%5.2lf%s\\n'";
2012-05-23 10:18:14 +00:00
if (!$nototal) { $rrd_options .= " GPRINT:tot".$rrd['ds'].$i.":%6.2lf%s".rrdtool_escape($total_units).""; }
2011-03-17 10:57:51 +00:00
$rrd_options .= " COMMENT:'\\n'";
}
2012-04-21 00:36:55 +00:00
if ($_GET['previous'] == "yes")
2012-04-20 13:00:00 +00:00
{
if (is_numeric($multiplier))
{
$rrd_options .= " CDEF:X=" . $thingX . $plusesX.",".$multiplier. ",*";
} elseif (is_numeric($divider))
{
$rrd_options .= " CDEF:X=" . $thingX . $plusesX.",".$divider. ",/";
2012-04-21 00:36:55 +00:00
} else
2012-04-20 13:00:00 +00:00
{
$rrd_options .= " CDEF:X=" . $thingX . $plusesX;
}
$rrd_options .= " AREA:X#99999999:";
$rrd_options .= " LINE1.25:X#666666:";
}
?>