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")
|
|
|
|
{
|
|
|
|
$descr_len=24;
|
|
|
|
} else {
|
|
|
|
$descr_len=12;
|
|
|
|
$descr_len += round(($width - 250) / 8);
|
|
|
|
}
|
|
|
|
|
2011-09-26 16:33:13 +00:00
|
|
|
if ($nototal) { $descrlen += "2"; $unitlen += "2";}
|
2011-04-22 14:59:10 +00:00
|
|
|
$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
|
|
|
|
2011-04-22 14:59:10 +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'])
|
2011-09-21 10:53:08 +00:00
|
|
|
{
|
|
|
|
$colour = $rrd['colour'];
|
|
|
|
} else {
|
|
|
|
if (!$config['graph_colours'][$colours][$colour_iter]) { $colour_iter = 0; }
|
|
|
|
$colour = $config['graph_colours'][$colours][$colour_iter];
|
|
|
|
$colour_iter++;
|
|
|
|
}
|
2011-04-22 14:59:10 +00:00
|
|
|
|
2011-10-25 09:47:45 +00:00
|
|
|
$descr = str_replace(":", "\:", substr(str_pad($rrd['descr'], $descr_len),0,$descr_len));
|
|
|
|
|
2011-09-21 11:59:59 +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)
|
2011-09-30 13:00:37 +00:00
|
|
|
{
|
|
|
|
$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 ";
|
|
|
|
}
|
2011-04-22 14:59:10 +00:00
|
|
|
|
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 = ",+";
|
|
|
|
}
|
|
|
|
|
2011-04-22 14:59:10 +00:00
|
|
|
## Suppress totalling?
|
2011-04-07 19:07:47 +00:00
|
|
|
if (!$nototal)
|
2011-03-17 10:57:51 +00:00
|
|
|
{
|
2011-09-21 11:59:59 +00:00
|
|
|
$rrd_options .= " VDEF:tot".$rrd['ds'].$i."=".$rrd['ds'].$i.",TOTAL";
|
2009-10-28 13:52:39 +00:00
|
|
|
}
|
|
|
|
|
2011-04-22 14:59:10 +00:00
|
|
|
## This this not the first entry?
|
2011-03-17 10:57:51 +00:00
|
|
|
if ($i) { $stack="STACK"; }
|
2011-04-07 19:07:47 +00:00
|
|
|
# if we've been passed a multiplier we must make a CDEF based on it!
|
2011-09-21 11:59:59 +00:00
|
|
|
$g_defname = $rrd['ds'];
|
2011-04-07 19:07:47 +00:00
|
|
|
if (is_numeric($multiplier))
|
|
|
|
{
|
2011-09-21 11:59:59 +00:00
|
|
|
$g_defname = $rrd['ds'] . "_cdef";
|
|
|
|
$rrd_options .= " CDEF:" . $g_defname . $i . "=" . $rrd['ds'] . $i . "," . $multiplier . ",*";
|
2012-04-05 16:21:54 +00:00
|
|
|
$rrd_options .= " CDEF:" . $g_defname . $i . "min=" . $rrd['ds'] . $i . "min," . $multiplier . ",*";
|
2011-09-21 11:59:59 +00:00
|
|
|
$rrd_options .= " CDEF:" . $g_defname . $i . "max=" . $rrd['ds'] . $i . "max," . $multiplier . ",*";
|
2011-09-20 09:55:11 +00:00
|
|
|
|
2011-04-22 14:59:10 +00:00
|
|
|
## If we've been passed a divider (divisor!) we make a CDEF for it.
|
|
|
|
} elseif (is_numeric($divider))
|
|
|
|
{
|
2011-09-21 11:59:59 +00:00
|
|
|
$g_defname = $rrd['ds'] . "_cdef";
|
|
|
|
$rrd_options .= " CDEF:" . $g_defname . $i . "=" . $rrd['ds'] . $i . "," . $divider . ",/";
|
2012-04-05 16:21:54 +00:00
|
|
|
$rrd_options .= " CDEF:" . $g_defname . $i . "min=" . $rrd['ds'] . $i . "min," . $divider . ",/";
|
2011-09-21 11:59:59 +00:00
|
|
|
$rrd_options .= " CDEF:" . $g_defname . $i . "max=" . $rrd['ds'] . $i . "max," . $divider . ",/";
|
2011-04-07 19:07:47 +00:00
|
|
|
}
|
2011-03-17 10:57:51 +00:00
|
|
|
|
2011-04-22 14:59:10 +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)
|
2011-04-22 14:59:10 +00:00
|
|
|
{
|
2011-09-21 11:59:59 +00:00
|
|
|
$t_defname = $rrd['ds'];
|
2011-04-22 14:59:10 +00:00
|
|
|
} 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'";
|
2011-04-22 14:59:10 +00:00
|
|
|
|
2011-09-21 11:59:59 +00:00
|
|
|
if (!$nototal) { $rrd_options .= " GPRINT:tot".$rrd['ds'].$i.":%6.2lf%s".str_replace("%", "%%", $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:";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-04-07 19:07:47 +00:00
|
|
|
?>
|