diff --git a/includes/html/graphs/device/uptime.inc.php b/includes/html/graphs/device/uptime.inc.php
index 822baebb99..ed79368894 100644
--- a/includes/html/graphs/device/uptime.inc.php
+++ b/includes/html/graphs/device/uptime.inc.php
@@ -9,6 +9,10 @@ $ds = 'uptime';
$colours = 'greens';
$float_precision = 3;
-$descr = '';
+$descr = 'Uptime';
+
+$munge = true;
+
+$unit_text = 'Days';
require 'includes/html/graphs/generic_stats.inc.php';
diff --git a/includes/html/graphs/generic_stats.inc.php b/includes/html/graphs/generic_stats.inc.php
index c879891e9b..d0738c5082 100644
--- a/includes/html/graphs/generic_stats.inc.php
+++ b/includes/html/graphs/generic_stats.inc.php
@@ -17,6 +17,10 @@ require 'includes/html/graphs/common.inc.php';
$stacked = generate_stacked_graphs();
+if (! isset($munge)) {
+ $munge = false;
+}
+
if (! isset($colours)) {
$colours = 'rainbow_stats_purple';
}
@@ -108,15 +112,30 @@ if ($height > 25) {
$descr_1w = \LibreNMS\Data\Store\Rrd::fixedSafeDescr('1 week avg', $descr_len);
}
-$id = 'ds' . $i;
+$id = 'ds0';
+if ($munge) {
+ $id = 'dsm0';
+}
-$rrd_options .= ' DEF:' . $id . "=$filename:$ds:AVERAGE";
+$rrd_options .= ' DEF:ds0' . "=$filename:$ds:AVERAGE";
+
+$munge_helper = '';
+if ($munge) {
+ if (! isset($munge_opts)) {
+ $munge_opts = '86400,/';
+ }
+ $rrd_options .= ' CDEF:dsm0=ds0,' . $munge_opts;
+ $munge_helper = 'ds';
+}
$rrd_optionsb .= ' AREA:' . $id . '#' . $colourA . $colourAalpha;
$rrd_optionsb .= ' LINE1.25:' . $id . '#' . $colour . ":'$descr'";
if ($height > 25) {
- $rrd_options .= ' DEF:' . $id . "1h=$filename:$ds:AVERAGE:step=3600";
+ $rrd_options .= ' DEF:' . $id . "1h$munge_helper=$filename:$ds:AVERAGE:step=3600";
+ if ($munge) {
+ $rrd_options .= ' CDEF:dsm01h=dsm01hds,' . $munge_opts;
+ }
$rrd_options .= ' VDEF:' . $id . '50th=' . $id . ',50,PERCENTNAN';
$rrd_options .= ' VDEF:' . $id . '25th=' . $id . ',25,PERCENTNAN';
$rrd_options .= ' VDEF:' . $id . '75th=' . $id . ',75,PERCENTNAN';
@@ -130,12 +149,18 @@ if ($height > 25) {
}
// displays nan if less than 17 hours
if ($time_diff >= 61200) {
- $rrd_options .= ' DEF:' . $id . "1d=$filename:$ds:AVERAGE:step=86400";
+ $rrd_options .= ' DEF:' . $id . "1d$munge_helper=$filename:$ds:AVERAGE:step=86400";
+ if ($munge) {
+ $rrd_options .= ' CDEF:dsm01d=dsm01dds,' . $munge_opts;
+ }
}
// weekly breaks and causes issues if it is less than 8 days
if ($time_diff >= 691200) {
- $rrd_options .= ' DEF:' . $id . "1w=$filename:$ds:AVERAGE:step=604800";
+ $rrd_options .= ' DEF:' . $id . "1w$munge_helper=$filename:$ds:AVERAGE:step=604800";
+ if ($munge) {
+ $rrd_options .= ' CDEF:dsm01w=dsm01wds,' . $munge_opts;
+ }
}
$rrd_optionsb .= ' GPRINT:' . $id . ':LAST:%5.' . $float_precision . 'lf%s' . $units . ' GPRINT:' . $id . ':MIN:%5.' . $float_precision . 'lf%s' . $units;