Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

91 lines
2.8 KiB
PHP
Raw Permalink Normal View History

2009-10-27 13:04:16 +00:00
<?php
2016-07-22 14:29:29 -05:00
/*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
2016-07-22 14:29:29 -05:00
*
* @package LibreNMS
* @subpackage graphs
2021-02-09 00:29:04 +01:00
* @link https://www.librenms.org
* @copyright 2017 LibreNMS
* @author LibreNMS Contributors
*/
2016-07-22 14:29:29 -05:00
2019-04-11 23:26:42 -05:00
require 'includes/html/graphs/common.inc.php';
$stacked = generate_stacked_graphs();
if (! isset($descr_len)) {
$descr_len = 12;
}
2009-10-27 13:04:16 +00:00
if ($nototal) {
$descr_len += '2';
$unitlen += '2';
}
2011-09-30 19:15:58 +00:00
$rrd_options .= " COMMENT:'" . \LibreNMS\Data\Store\Rrd::fixedSafeDescr($unit_text, $descr_len) . " Now Min Max Avg\l'";
2009-10-27 13:04:16 +00:00
$i = 0;
2011-09-30 19:15:58 +00:00
$iter = 0;
2009-10-27 13:04:16 +00:00
foreach ($rrd_list as $rrd) {
2016-07-22 14:29:29 -05:00
// get the color for this data set
2016-08-18 20:28:22 -05:00
if (isset($rrd['colour'])) {
2016-07-22 14:29:29 -05:00
$colour = $rrd['colour'];
} else {
2019-06-23 00:29:12 -05:00
if (! \LibreNMS\Config::get("graph_colours.$colours.$iter")) {
2016-07-22 14:29:29 -05:00
$iter = 0;
}
2019-06-23 00:29:12 -05:00
$colour = \LibreNMS\Config::get("graph_colours.$colours.$iter");
2016-07-22 14:29:29 -05:00
$iter++;
}
2009-10-27 13:04:16 +00:00
2015-07-01 08:08:06 +10:00
if (! empty($rrd['area']) && empty($rrd['areacolour'])) {
$rrd['areacolour'] = $colour . '20';
2015-07-01 08:08:06 +10:00
}
2009-10-27 13:04:16 +00:00
$ds = $rrd['ds'];
$filename = $rrd['filename'];
2011-09-30 19:15:58 +00:00
2021-03-28 17:25:30 -05:00
$descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr'], $descr_len);
2009-10-27 13:04:16 +00:00
$id = 'ds' . $i;
$rrd_options .= ' DEF:' . $id . "=$filename:$ds:AVERAGE";
2009-10-27 13:04:16 +00:00
if ($simple_rrd) {
$rrd_options .= ' CDEF:' . $id . 'min=' . $id . ' ';
$rrd_options .= ' CDEF:' . $id . 'max=' . $id . ' ';
2016-08-18 20:28:22 -05:00
} else {
$rrd_options .= ' DEF:' . $id . "min=$filename:$ds:MIN";
$rrd_options .= ' DEF:' . $id . "max=$filename:$ds:MAX";
}
2011-09-18 22:55:29 +00:00
if ($rrd['invert']) {
$rrd_options .= ' CDEF:' . $id . 'i=' . $id . ',' . $stacked['stacked'] . ',*';
$rrd_optionsb .= ' LINE1.25:' . $id . 'i#' . $colour . ":'$descr'";
if (! empty($rrd['areacolour'])) {
$rrd_optionsb .= ' AREA:' . $id . 'i#' . $rrd['areacolour'];
}
2016-08-18 20:28:22 -05:00
} else {
$rrd_optionsb .= ' LINE1.25:' . $id . '#' . $colour . ":'$descr'";
if (! empty($rrd['areacolour'])) {
$rrd_optionsb .= ' AREA:' . $id . '#' . $rrd['areacolour'];
}
}
2009-10-27 13:04:16 +00:00
2020-06-25 21:51:55 +02:00
$rrd_optionsb .= ' GPRINT:' . $id . ':LAST:%5.' . $float_precision . 'lf%s' . $units . ' GPRINT:' . $id . 'min:MIN:%5.' . $float_precision . 'lf%s' . $units;
$rrd_optionsb .= ' GPRINT:' . $id . 'max:MAX:%5.' . $float_precision . 'lf%s' . $units . ' GPRINT:' . $id . ":AVERAGE:'%5." . $float_precision . "lf%s$units\\n'";
2011-09-30 13:09:14 +00:00
$i++;
}
2011-03-17 10:57:51 +00:00
2011-09-19 08:54:48 +00:00
$rrd_options .= $rrd_optionsb;
$rrd_options .= ' HRULE:0#555555';
unset($stacked);