From 82ea950263d362f81c70990d73156b593781225d Mon Sep 17 00:00:00 2001 From: SniperVegeta Date: Sat, 14 Sep 2019 23:45:38 +0200 Subject: [PATCH] Extended 'port previous' graphs (#10556) * Update ping_perf.inc.php * Update poller_perf.inc.php * Update generic_data.inc.php * Update generic_multi_seperated.inc.php * Update poller_modules_perf.inc.php * Update poller_perf.inc.php * Update ping_perf.inc.php remove // comment (old code) * Update poller_perf.inc.php remove // comment (old code) * Update generic_multi_seperated.inc.php remove // comment (old code) * Update poller_perf.inc.php remove // comment (old code) --- includes/html/graphs/device/ping_perf.inc.php | 9 +++ .../html/graphs/device/poller_perf.inc.php | 9 +++ includes/html/graphs/generic_data.inc.php | 42 +++++++++- .../graphs/generic_multi_seperated.inc.php | 78 ++++++++++++++++--- .../graphs/global/poller_modules_perf.inc.php | 36 +++++++-- .../html/graphs/global/poller_perf.inc.php | 25 +++++- 6 files changed, 181 insertions(+), 18 deletions(-) diff --git a/includes/html/graphs/device/ping_perf.inc.php b/includes/html/graphs/device/ping_perf.inc.php index ba0ca656f9..950995f9e2 100644 --- a/includes/html/graphs/device/ping_perf.inc.php +++ b/includes/html/graphs/device/ping_perf.inc.php @@ -23,3 +23,12 @@ $rrd_options .= " 'COMMENT:Milliseconds Cur Min Max Avg\\n'"; $rrd_options .= ' LINE1.25:ping#36393D:Ping'; $rrd_options .= ' GPRINT:ping:LAST:%14.2lf GPRINT:ping:AVERAGE:%6.2lf'; $rrd_options .= " GPRINT:ping:MAX:%6.2lf 'GPRINT:ping:AVERAGE:%6.2lf\\n'"; + +if ($_GET['previous'] == 'yes') { + $rrd_options .= " COMMENT:' \\n'"; + $rrd_options .= " DEF:pingX=$rrd_filename:ping:AVERAGE:start=$prev_from:end=$from"; + $rrd_options .= " SHIFT:pingX:$period"; + $rrd_options .= " LINE1.25:pingX#CCCCCC:'Prev Ping'\t\t"; + $rrd_options .= " GPRINT:pingX:AVERAGE:%6.2lf"; + $rrd_options .= " GPRINT:pingX:MAX:%6.2lf 'GPRINT:pingX:AVERAGE:%6.2lf\\n'"; +} diff --git a/includes/html/graphs/device/poller_perf.inc.php b/includes/html/graphs/device/poller_perf.inc.php index c6a6225615..7bd8e94821 100644 --- a/includes/html/graphs/device/poller_perf.inc.php +++ b/includes/html/graphs/device/poller_perf.inc.php @@ -23,3 +23,12 @@ $rrd_options .= " 'COMMENT:Seconds Cur Min Max Avg\\n'"; $rrd_options .= ' LINE1.25:poller#36393D:Poller'; $rrd_options .= ' GPRINT:poller:LAST:%6.2lf GPRINT:poller:MIN:%6.2lf'; $rrd_options .= " GPRINT:poller:MAX:%6.2lf 'GPRINT:poller:AVERAGE:%6.2lf\\n'"; + +if ($_GET['previous'] == 'yes') { + $rrd_options .= " COMMENT:' \\n'"; + $rrd_options .= " DEF:pollerX=$rrd_filename:poller:AVERAGE:start=$prev_from:end=$from"; + $rrd_options .= " SHIFT:pollerX:$period"; + $rrd_options .= " LINE1.25:pollerX#CCCCCC:'Prev Poller'\t"; + $rrd_options .= " GPRINT:pollerX:MIN:%6.2lf"; + $rrd_options .= " GPRINT:pollerX:MAX:%6.2lf 'GPRINT:pollerX:AVERAGE:%6.2lf\\n'"; +} diff --git a/includes/html/graphs/generic_data.inc.php b/includes/html/graphs/generic_data.inc.php index 090bd6daa2..6ae132f3dc 100644 --- a/includes/html/graphs/generic_data.inc.php +++ b/includes/html/graphs/generic_data.inc.php @@ -52,13 +52,19 @@ if ($_GET['previous'] == 'yes') { if ($multiplier) { $rrd_options .= ' DEF:p' . $out . 'octetsX=' . $rrd_filename_out . ':' . $ds_out . ':AVERAGE:start=' . $prev_from . ':end=' . $from; $rrd_options .= ' DEF:p' . $in . 'octetsX=' . $rrd_filename_in . ':' . $ds_in . ':AVERAGE:start=' . $prev_from . ':end=' . $from; + $rrd_options .= ' DEF:p' . $out . 'octets_maxX=' . $rrd_filename_out . ':' . $ds_out . ':MAX:start=' . $prev_from . ':end=' . $from; + $rrd_options .= ' DEF:p' . $in . 'octets_maxX=' . $rrd_filename_in . ':' . $ds_in . ':MAX:start=' . $prev_from . ':end=' . $from; $rrd_options .= ' SHIFT:p' . $out . "octetsX:$period"; $rrd_options .= ' SHIFT:p' . $in . "octetsX:$period"; $rrd_options .= " CDEF:inoctetsX=pinoctetsX,$multiplier,*"; $rrd_options .= " CDEF:outoctetsX=poutoctetsX,$multiplier,*"; + $rrd_options .= " CDEF:inoctets_maxX=pinoctets_maxX,$multiplier,*"; + $rrd_options .= " CDEF:outoctets_maxX=poutoctets_maxX,$multiplier,*"; } else { $rrd_options .= ' DEF:' . $out . 'octetsX=' . $rrd_filename_out . ':' . $ds_out . ':AVERAGE:start=' . $prev_from . ':end=' . $from; $rrd_options .= ' DEF:' . $in . 'octetsX=' . $rrd_filename_in . ':' . $ds_in . ':AVERAGE:start=' . $prev_from . ':end=' . $from; + $rrd_options .= ' DEF:' . $out . 'octets_maxX=' . $rrd_filename_out . ':' . $ds_out . ':MAX:start=' . $prev_from . ':end=' . $from; + $rrd_options .= ' DEF:' . $in . 'octets_maxX=' . $rrd_filename_in . ':' . $ds_in . ':MAX:start=' . $prev_from . ':end=' . $from; $rrd_options .= ' SHIFT:' . $out . "octetsX:$period"; $rrd_options .= ' SHIFT:' . $in . "octetsX:$period"; } @@ -66,11 +72,19 @@ if ($_GET['previous'] == 'yes') { $rrd_options .= ' CDEF:octetsX=inoctetsX,outoctetsX,+'; $rrd_options .= ' CDEF:doutoctetsX=outoctetsX,' . $stacked['stacked'] . ',*'; $rrd_options .= ' CDEF:outbitsX=outoctetsX,8,*'; + $rrd_options .= ' CDEF:outbits_maxX=outoctets_maxX,8,*'; + $rrd_options .= ' CDEF:doutoctets_maxX=outoctets_maxX,' . $stacked['stacked'] . ',*'; $rrd_options .= ' CDEF:doutbitsX=doutoctetsX,8,*'; + $rrd_options .= ' CDEF:doutbits_maxX=doutoctets_maxX,8,*'; $rrd_options .= ' CDEF:inbitsX=inoctetsX,8,*'; + $rrd_options .= ' CDEF:inbits_maxX=inoctets_maxX,8,*'; $rrd_options .= ' VDEF:totinX=inoctetsX,TOTAL'; $rrd_options .= ' VDEF:totoutX=outoctetsX,TOTAL'; $rrd_options .= ' VDEF:totX=octetsX,TOTAL'; + $rrd_options .= ' CDEF:dpercentile_outnX=doutbitsX,' . $stacked['stacked'] . ',*'; + $rrd_options .= ' VDEF:dpercentile_outnpX=dpercentile_outnX,' . Config::get('percentile_value') . ',PERCENT'; + $rrd_options .= ' CDEF:dpercentile_outnpnX=doutbitsX,doutbitsX,-,dpercentile_outnpX,' . $stacked['stacked'] . ',*,+'; + $rrd_options .= ' VDEF:dpercentile_outX=dpercentile_outnpnX,FIRST'; } $rrd_options .= ' CDEF:octets=inoctets,outoctets,+'; @@ -86,6 +100,10 @@ $rrd_options .= ' CDEF:inbits_max=inoctets_max,8,*'; if (Config::get('rrdgraph_real_percentile')) { $rrd_options .= ' CDEF:highbits=inoctets,outoctets,MAX,8,*'; $rrd_options .= ' VDEF:percentilehigh=highbits,' . Config::get('percentile_value') . ',PERCENT'; + if ($_GET['previous'] == 'yes') { + $rrd_options .= ' CDEF:highbitsX=inoctetsX,outoctetsX,MAX:start=' . $prev_from . ':end=' . $from . ',8,*'; + $rrd_options .= ' VDEF:percentilehighX=highbitsX,' . Config::get('percentile_value') . ',PERCENT'; + } } $rrd_options .= ' VDEF:totin=inoctets,TOTAL'; @@ -99,11 +117,19 @@ $rrd_options .= ' VDEF:dpercentile_out=dpercentile_outnpn,FIRST'; if ($format == 'octets' || $format == 'bytes') { $rrd_options .= ' VDEF:percentile_in=inoctets,' . Config::get('percentile_value') . ',PERCENT'; $rrd_options .= ' VDEF:percentile_out=outoctets,' . Config::get('percentile_value') . ',PERCENT'; + if ($_GET['previous'] == 'yes') { + $rrd_options .= ' VDEF:percentile_inX=inoctetsX,' . Config::get('percentile_value') . ',PERCENT'; + $rrd_options .= ' VDEF:percentile_outX=outoctetsX,' . Config::get('percentile_value') . ',PERCENT'; + } $units = 'Bps'; $format = 'octets'; } else { $rrd_options .= ' VDEF:percentile_in=inbits,' . Config::get('percentile_value') . ',PERCENT'; $rrd_options .= ' VDEF:percentile_out=outbits,' . Config::get('percentile_value') . ',PERCENT'; + if ($_GET['previous'] == 'yes') { + $rrd_options .= ' VDEF:percentile_inX=inbitsX,' . Config::get('percentile_value') . ',PERCENT'; + $rrd_options .= ' VDEF:percentile_outX=outbitsX,' . Config::get('percentile_value') . ',PERCENT'; + } $units = 'bps'; $format = 'bits'; } @@ -151,8 +177,20 @@ if ($to > time()) { } if ($_GET['previous'] == 'yes') { - $rrd_options .= ' LINE1.25:in' . $format . "X#009900:'Prev In \\n'"; - $rrd_options .= ' LINE1.25:dout' . $format . "X#000099:'Prev Out'"; + $rrd_options .= " COMMENT:' \\n'"; + $rrd_options .= ' LINE1.25:in' . $format . "X#333300:'Prev In '\t"; + $rrd_options .= ' GPRINT:in' . $format . 'X:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:in' . $format . '_maxX:MAX:%6.2lf%s'; + $rrd_options .= " GPRINT:percentile_inX:%6.2lf%s\\n"; + $rrd_options .= ' LINE1.25:dout' . $format . "X#000099:'Prev Out '\t"; + $rrd_options .= ' GPRINT:out' . $format . 'X:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:out' . $format . '_maxX:MAX:%6.2lf%s'; + $rrd_options .= " GPRINT:percentile_outX:%6.2lf%s\\n"; + $rrd_options .= " GPRINT:totX:'Total %6.2lf%sB'"; + $rrd_options .= " GPRINT:totinX:'(In %6.2lf%sB'"; + $rrd_options .= " GPRINT:totoutX:'Out %6.2lf%sB)\\l'"; + $rrd_options .= ' LINE1:percentile_inX#00aaaa'; + $rrd_options .= ' LINE1:dpercentile_outX#00aaaa'; } unset($stacked); diff --git a/includes/html/graphs/generic_multi_seperated.inc.php b/includes/html/graphs/generic_multi_seperated.inc.php index 1942ef099e..0cf685d837 100644 --- a/includes/html/graphs/generic_multi_seperated.inc.php +++ b/includes/html/graphs/generic_multi_seperated.inc.php @@ -33,8 +33,14 @@ if ($format == 'octets' || $format == 'bytes') { $i = 0; $rrd_options .= " COMMENT:'$units_descr Now Avg Max'"; -if (!$nototal) { - $rrd_options .= " COMMENT:'Total'"; +if (!$args['nototal']) { + $rrd_options .= " COMMENT:' Total'"; +} +if ($_GET['previous']) { + $rrd_options .= " COMMENT:' \t P Avg P Max'"; + if (!$args['nototal']) { + $rrd_options .= " COMMENT:' P Total'"; + } } $rrd_options .= " COMMENT:'\\n'"; @@ -66,13 +72,13 @@ foreach ($rrd_list as $rrd) { if ($_GET['previous']) { $rrd_options .= ' DEF:inB' . $i . 'X=' . $rrd['filename'] . ':' . $ds_in . ':AVERAGE:start=' . $prev_from . ':end=' . $from; $rrd_options .= ' DEF:outB' . $i . 'X=' . $rrd['filename'] . ':' . $ds_out . ':AVERAGE:start=' . $prev_from . ':end=' . $from; + $rrd_options .= ' CDEF:octets' . $i . 'X=inB' . $i . 'X,outB' . $i . 'X,+'; + $rrd_options .= ' CDEF:inbits' . $i . 'X=inB' . $i . 'X' . ",$multiplier,* "; + $rrd_options .= ' CDEF:outbits' . $i . 'X=outB' . $i . 'X' . ",$multiplier,*"; + $rrd_options .= ' CDEF:outbits' . $i . '_negX=outbits' . $i . 'X,' . $stacked['stacked'] . ',*'; + $rrd_options .= ' CDEF:bits' . $i . 'X=inbits' . $i . 'X,outbits' . $i . 'X,+'; $rrd_options .= ' SHIFT:inB' . $i . "X:$period"; $rrd_options .= ' SHIFT:outB' . $i . "X:$period"; - $in_thingX .= $seperatorX . 'inB' . $i . 'X,UN,0,' . 'inB' . $i . 'X,IF'; - $out_thingX .= $seperatorX . 'outB' . $i . 'X,UN,0,' . 'outB' . $i . 'X,IF'; - $plusesX .= $plusX; - $seperatorX = ','; - $plusX = ',+'; } if (!$args['nototal']) { @@ -85,6 +91,16 @@ foreach ($rrd_list as $rrd) { $rrd_options .= ' VDEF:totinB' . $i . '=inB' . $i . ',TOTAL'; $rrd_options .= ' VDEF:totoutB' . $i . '=outB' . $i . ',TOTAL'; $rrd_options .= ' VDEF:tot' . $i . '=octets' . $i . ',TOTAL'; + if ($_GET['previous']) { + $in_thingX .= $seperatorX . 'inB' . $i . 'X,UN,0,' . 'inB' . $i . 'X,IF'; + $out_thingX .= $seperatorX . 'outB' . $i . 'X,UN,0,' . 'outB' . $i . 'X,IF'; + $plusesX .= $plusX; + $seperatorX = ','; + $plusX = ',+'; + $rrd_options .= ' VDEF:totinB' . $i . 'X=inB' . $i . 'X,TOTAL'; + $rrd_options .= ' VDEF:totoutB' . $i . 'X=outB' . $i . 'X,TOTAL'; + $rrd_options .= ' VDEF:tot' . $i . 'X=octets' . $i . 'X,TOTAL'; + } } if ($i) { @@ -96,10 +112,19 @@ foreach ($rrd_list as $rrd) { $rrd_options .= ' GPRINT:inbits' . $i . ':AVERAGE:%6.2lf%s'; $rrd_options .= ' GPRINT:inbits' . $i . ':MAX:%6.2lf%s'; - if (!$nototal) { + if (!$args['nototal']) { $rrd_options .= ' GPRINT:totinB' . $i . ":%6.2lf%s$total_units"; } + if ($_GET['previous'] == 'yes') { + $rrd_options .= " COMMENT:' \t'"; + $rrd_options .= ' GPRINT:inbits' . $i . 'X:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbits' . $i . 'X:MAX:%6.2lf%s'; + if (!$args['nototal']) { + $rrd_options .= ' GPRINT:totinB' . $i . 'X' . ":%6.2lf%s$total_units"; + } + } + $rrd_options .= " COMMENT:'\\n'"; $rrd_optionsb .= ' AREA:outbits' . $i . '_neg#' . $colour_out . $stacked['transparency'] . ":$stack"; $rrd_options .= ' HRULE:999999999999999#' . $colour_out . ":'" . str_pad('', $rrddescr_len + 1) . "Out'"; @@ -107,9 +132,18 @@ foreach ($rrd_list as $rrd) { $rrd_options .= ' GPRINT:outbits' . $i . ':AVERAGE:%6.2lf%s'; $rrd_options .= ' GPRINT:outbits' . $i . ':MAX:%6.2lf%s'; - if (!$nototal) { + if (!$args['nototal']) { $rrd_options .= ' GPRINT:totoutB' . $i . ":%6.2lf%s$total_units"; } + + if ($_GET['previous'] == 'yes') { + $rrd_options .= " COMMENT:' \t'"; + $rrd_options .= ' GPRINT:outbits' . $i . 'X:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbits' . $i . 'X:MAX:%6.2lf%s'; + if (!$args['nototal']) { + $rrd_options .= ' GPRINT:totoutB' . $i . 'X' . ":%6.2lf%s$total_units"; + } + } $rrd_options .= " COMMENT:'\\n'"; $i++; @@ -132,6 +166,11 @@ if ($_GET['previous'] == 'yes') { $rrd_options .= ' VDEF:dpercentile_outXperc=dpercentile_outXn,' . Config::get('percentile_value') . ',PERCENT'; $rrd_options .= ' CDEF:dpercentile_outXnd=doutbitsX,doutbitsX,-,dpercentile_outXperc,-1,*,+'; $rrd_options .= ' VDEF:dpercentile_outXpercn=dpercentile_outXnd,FIRST'; + $rrd_options .= ' VDEF:totinX=inBX,TOTAL'; + $rrd_options .= ' VDEF:aveinX=inbitsX,AVERAGE'; + $rrd_options .= ' VDEF:totoutX=outBX,TOTAL'; + $rrd_options .= ' VDEF:aveoutX=outbitsX,AVERAGE'; + $rrd_options .= ' VDEF:totX=octetsX,TOTAL'; } if ($_GET['previous'] == 'yes') { @@ -184,6 +223,27 @@ if (!$args['nototal']) { $rrd_options .= ' GPRINT:bits:MAX:%6.2lf%s'; $rrd_options .= " GPRINT:tot:%6.2lf%s$total_units"; $rrd_options .= " COMMENT:'\\n'"; + if ($_GET['previous'] == 'yes') { + $rrd_options .= " COMMENT:' \\n'"; + $rrd_options .= " COMMENT:' \t\t\t\t\t\t'"; + $rrd_options .= " HRULE:999999999999999#FFFFFF:'" . str_pad('Perv Total', $rrddescr_len + 1) . "In '\t\t"; + $rrd_options .= ' GPRINT:inbitsX:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:inbitsX:MAX:%6.2lf%s'; + $rrd_options .= " GPRINT:totinX:%6.2lf%s$total_units"; + $rrd_options .= " COMMENT:'\\n'"; + $rrd_options .= " COMMENT:' \t\t\t\t\t\t'"; + $rrd_options .= " HRULE:999999999999990#FFFFFF:'" . str_pad('', $rrddescr_len + 1) . "Out'\t\t"; + $rrd_options .= ' GPRINT:outbitsX:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:outbitsX:MAX:%6.2lf%s'; + $rrd_options .= " GPRINT:totoutX:%6.2lf%s$total_units"; + $rrd_options .= " COMMENT:'\\n'"; + $rrd_options .= " COMMENT:' \t\t\t\t\t\t'"; + $rrd_options .= " HRULE:999999999999990#FFFFFF:'" . str_pad('', $rrddescr_len + 1) . "Agg'\t\t"; + $rrd_options .= ' GPRINT:bitsX:AVERAGE:%6.2lf%s'; + $rrd_options .= ' GPRINT:bitsX:MAX:%6.2lf%s'; + $rrd_options .= " GPRINT:totX:%6.2lf%s$total_units"; + $rrd_options .= " COMMENT:'\\n'"; + } } $rrd_options .= $rrd_optionsb; diff --git a/includes/html/graphs/global/poller_modules_perf.inc.php b/includes/html/graphs/global/poller_modules_perf.inc.php index 6ea9f37c69..1a445dcff8 100644 --- a/includes/html/graphs/global/poller_modules_perf.inc.php +++ b/includes/html/graphs/global/poller_modules_perf.inc.php @@ -38,7 +38,9 @@ sort($modules); foreach ($modules as $module_index => $module) { $cdef = []; $suffix = ''; - + $cdefX = []; + $suffixX = ''; + foreach ($hostnames as $index => $hostname) { $rrd_filename = rrd_name($hostname, ['poller-perf', $module]); if (rrdtool_check_rrd_exists($rrd_filename)) { @@ -48,6 +50,14 @@ foreach ($modules as $module_index => $module) { $cdef[] = $module . $index . $suffix; $suffix = ',+'; + if ($_GET['previous'] == 'yes') { + $rrd_options .= " DEF:{$module}RawX$index=$rrd_filename:poller:AVERAGE:start=$prev_from:end=$from"; + // change undefined to 0 + $rrd_options .= " CDEF:{$module}X$index={$module}RawX$index,UN,0,{$module}RawX$index,IF"; + $rrd_options .= " SHIFT:{$module}X$index:$period"; + $cdefX[] = $module . 'X' . $index . $suffixX; + $suffixX = ',+'; + } } } @@ -57,16 +67,32 @@ foreach ($modules as $module_index => $module) { } else { // have data for this module, display it $rrd_options .= " CDEF:$module=" . implode(',', $cdef); + if ($_GET['previous']) { + $rrd_options .= " CDEF:{$module}X=" . implode(',', $cdefX); + } } } -$rrd_options .= " 'COMMENT:Seconds Cur Min Max Avg\\n'"; +$rrd_options .= " 'COMMENT:Seconds Cur Min Max Avg'"; + +if ($_GET['previous']) { + $rrd_options .= " COMMENT:' \t P Min P Max P Avg'"; +} + +$rrd_options .= " COMMENT:'\\n'"; foreach ($modules as $index => $module) { $color = $colors[$index % count($colors)]; - $rrd_options .= " AREA:$module#$color:'" . rrdtool_escape($module, 16) ."':STACK"; - $rrd_options .= " GPRINT:$module:LAST:%6.2lf GPRINT:$module:MIN:%6.2lf"; - $rrd_options .= " GPRINT:$module:MAX:%6.2lf 'GPRINT:$module:AVERAGE:%6.2lf\\n'"; + $rrd_options .= " GPRINT:$module:MAX:%6.2lf 'GPRINT:$module:AVERAGE:%6.2lf'"; + if ($_GET['previous']) { + $rrd_options .= ' AREA:' .$module. 'X#99999999' . $stacked['transparency'] . ':'; + $rrd_options .= ' LINE1.25:' .$module. 'X#666666:'; + $rrd_options .= " COMMENT:'\t'"; + $rrd_options .= " GPRINT:{$module}X:MIN:%6.2lf"; + $rrd_options .= " GPRINT:{$module}X:MAX:%6.2lf"; + $rrd_options .= " GPRINT:{$module}X:AVERAGE:%6.2lf"; + } + $rrd_options .= " COMMENT:'\\n'"; } diff --git a/includes/html/graphs/global/poller_perf.inc.php b/includes/html/graphs/global/poller_perf.inc.php index e6b013402e..3729ab7a49 100644 --- a/includes/html/graphs/global/poller_perf.inc.php +++ b/includes/html/graphs/global/poller_perf.inc.php @@ -31,6 +31,8 @@ require 'includes/html/graphs/common.inc.php'; $cdef = []; $suffix = ''; +$cdefX = []; +$suffixX = ''; foreach (Device::pluck('hostname') as $index => $hostname) { $rrd_filename = rrd_name($hostname, 'poller-perf'); @@ -40,11 +42,30 @@ foreach (Device::pluck('hostname') as $index => $hostname) { $rrd_options .= " CDEF:poller$index=pollerRaw$index,UN,0,pollerRaw$index,IF"; $cdef[] = 'poller' . $index . $suffix; $suffix = ',+'; + if ($_GET['previous'] == 'yes') { + $rrd_options .= " DEF:pollerRawX$index=$rrd_filename:poller:AVERAGE:start=$prev_from:end=$from"; + // change undefined to 0 + $rrd_options .= " CDEF:pollerX$index=pollerRawX$index,UN,0,pollerRawX$index,IF"; + $rrd_options .= " SHIFT:pollerX$index:$period"; + $cdefX[] = 'pollerX' . $index . $suffixX; + $suffixX = ',+'; + } } } $rrd_options .= " CDEF:poller=" . implode(',', $cdef); -$rrd_options .= " 'COMMENT:Seconds Cur Min Max Avg\\n'"; +$rrd_options .= " CDEF:avgpol=poller," . count($cdef) .",/"; +$rrd_options .= " 'COMMENT:Seconds Cur Min Max Avg Avg device\\n'"; $rrd_options .= ' LINE1.25:poller#36393D:Poller'; $rrd_options .= ' GPRINT:poller:LAST:%6.2lf GPRINT:poller:MIN:%6.2lf'; -$rrd_options .= " GPRINT:poller:MAX:%6.2lf 'GPRINT:poller:AVERAGE:%6.2lf\\n'"; +$rrd_options .= ' GPRINT:poller:MAX:%6.2lf GPRINT:poller:AVERAGE:%6.2lf'; +$rrd_options .= " 'GPRINT:avgpol:AVERAGE:%6.2lf\\n'"; +if ($_GET['previous'] == 'yes') { + $rrd_options .= " COMMENT:' \\n'"; + $rrd_options .= " CDEF:pollerX=" . implode(',', $cdefX); + $rrd_options .= " CDEF:avgpolX=pollerX," . count($cdefX) .",/"; + $rrd_options .= " LINE1.25:pollerX#CCCCCC:'Prev Poller'\t"; + $rrd_options .= " GPRINT:pollerX:MIN:%6.2lf"; + $rrd_options .= ' GPRINT:pollerX:MAX:%6.2lf GPRINT:pollerX:AVERAGE:%6.2lf'; + $rrd_options .= " 'GPRINT:avgpolX:AVERAGE:%6.2lf\\n'"; +}