2009-10-28 13:52:39 +00:00
|
|
|
<?php
|
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
require 'includes/graphs/common.inc.php';
|
|
|
|
|
|
|
|
if ($width > '500') {
|
|
|
|
$descr_len = 24;
|
|
|
|
// FIXME may even be more imo?
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$descr_len = 12;
|
|
|
|
$descr_len += round(($width - 250) / 8);
|
2011-10-25 09:47:45 +00:00
|
|
|
}
|
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
if ($nototal) {
|
2015-11-15 11:48:39 +10:00
|
|
|
$descr_len += '2';
|
2015-07-10 13:36:21 +02:00
|
|
|
$unitlen += '2';
|
|
|
|
}
|
2011-04-22 14:59:10 +00:00
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
$unit_text = str_pad(truncate($unit_text, $unitlen), $unitlen);
|
|
|
|
|
|
|
|
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 '";
|
|
|
|
}
|
2011-10-25 09:47:45 +00:00
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
$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'";
|
2011-10-25 09:47:45 +00:00
|
|
|
}
|
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
$unitlen = '10';
|
|
|
|
if ($nototal) {
|
2015-11-15 11:48:39 +10:00
|
|
|
$descr_len += '2';
|
2015-07-10 13:36:21 +02:00
|
|
|
$unitlen += '2';
|
2011-03-17 10:57:51 +00:00
|
|
|
}
|
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
$unit_text = str_pad(truncate($unit_text, $unitlen), $unitlen);
|
|
|
|
|
|
|
|
$colour_iter = 0;
|
|
|
|
foreach ($rrd_list as $i => $rrd) {
|
|
|
|
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-04-20 13:00:00 +00:00
|
|
|
}
|
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
$descr = rrdtool_escape($rrd['descr'], $descr_len);
|
2012-04-20 13:00:00 +00:00
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
$rrd_options .= ' DEF:'.$rrd['ds'].$i.'='.$rrd['filename'].':'.$rrd['ds'].':AVERAGE ';
|
|
|
|
|
|
|
|
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 ';
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
$rrd_options .= ' VDEF:tot'.$rrd['ds'].$i.'='.$rrd['ds'].$i.',TOTAL';
|
|
|
|
}
|
|
|
|
|
|
|
|
// This this not the first entry?
|
|
|
|
if ($i) {
|
2015-11-15 11:48:39 +10:00
|
|
|
$stack = ':STACK';
|
2015-07-10 13:36:21 +02:00
|
|
|
}
|
2012-04-20 13:00:00 +00:00
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
// 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.',*';
|
|
|
|
|
|
|
|
// If we've been passed a divider (divisor!) we make a CDEF for it.
|
|
|
|
}
|
|
|
|
else if (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.',/';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Are our text values related to te multiplier/divisor or not?
|
|
|
|
if (isset($text_orig) && $text_orig) {
|
|
|
|
$t_defname = $rrd['ds'];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$t_defname = $g_defname;
|
|
|
|
}
|
|
|
|
|
2015-11-15 11:48:39 +10:00
|
|
|
$rrd_options .= ' AREA:'.$g_defname.$i.'#'.$colour.":'".$descr."'$stack";
|
2015-07-10 13:36:21 +02:00
|
|
|
|
|
|
|
$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'";
|
|
|
|
|
|
|
|
if (!$nototal) {
|
2015-11-15 11:48:39 +10:00
|
|
|
$rrd_options .= ' GPRINT:tot'.$rrd['ds'].$i.":%6.2lf%s'".rrdtool_escape($total_units)."'";
|
2015-07-10 13:36:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$rrd_options .= " COMMENT:'\\n'";
|
|
|
|
}//end foreach
|
|
|
|
|
|
|
|
if ($_GET['previous'] == 'yes') {
|
|
|
|
if (is_numeric($multiplier)) {
|
|
|
|
$rrd_options .= ' CDEF:X='.$thingX.$plusesX.','.$multiplier.',*';
|
|
|
|
}
|
|
|
|
else if (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:';
|
|
|
|
}
|