Files

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

55 lines
1.9 KiB
PHP
Raw Permalink Normal View History

<?php
$scale_min = '0';
$scale_max = '100';
2019-04-11 23:26:42 -05:00
require 'includes/html/graphs/common.inc.php';
2022-08-30 12:55:37 -05:00
$previous = $_GET['previous'] ?? 'no';
$rrd_options .= ' -b 1024';
$iter = '1';
2010-07-29 22:20:38 +00:00
$rrd_options .= " COMMENT:' Size Free % Used\\n'";
2011-03-17 14:27:03 +00:00
$hostname = gethostbyid($storage['device_id']);
$colour = 'CC0000';
$colour_area = 'ffaaaa';
2011-03-17 14:27:03 +00:00
2021-03-28 17:25:30 -05:00
$descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($storage['storage_descr'], 16);
2011-03-17 14:27:03 +00:00
2012-05-23 10:37:23 +00:00
$percentage = round($storage['storage_perc'], 0);
$background = \LibreNMS\Util\Color::percentage($percentage, $storage['storage_perc_warn']);
$rrd_options .= " DEF:used=$rrd_filename:used:AVERAGE";
$rrd_options .= " DEF:free=$rrd_filename:free:AVERAGE";
$rrd_options .= ' CDEF:size=used,free,+';
$rrd_options .= ' CDEF:perc=used,size,/,100,*';
$rrd_options .= ' AREA:perc#' . $background['right'] . ':';
$rrd_options .= ' LINE1.25:perc#' . $background['left'] . ":'$descr'";
$rrd_options .= ' GPRINT:size:LAST:%6.2lf%sB';
$rrd_options .= ' GPRINT:free:LAST:%6.2lf%sB';
$rrd_options .= ' GPRINT:perc:LAST:%5.2lf%%\\n';
2022-08-30 12:55:37 -05:00
if ($previous) {
2021-03-28 17:25:30 -05:00
$descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr('Prev ' . $storage['storage_descr'], 16);
$colour = '99999999';
$colour_area = '66666666';
$rrd_options .= " DEF:usedX=$rrd_filename:used:AVERAGE:start=" . $prev_from . ':end=' . $from;
$rrd_options .= " DEF:freeX=$rrd_filename:free:AVERAGE:start=" . $prev_from . ':end=' . $from;
$rrd_options .= " SHIFT:usedX:$period";
$rrd_options .= " SHIFT:freeX:$period";
$rrd_options .= ' CDEF:sizeX=usedX,freeX,+';
$rrd_options .= ' CDEF:percX=usedX,sizeX,/,100,*';
$rrd_options .= ' AREA:percX#' . $colour_area . ':';
$rrd_options .= ' LINE1.25:percX#' . $colour . ":'$descr'";
$rrd_options .= ' GPRINT:sizeX:LAST:%6.2lf%sB';
$rrd_options .= ' GPRINT:freeX:LAST:%6.2lf%sB';
$rrd_options .= ' GPRINT:percX:LAST:%5.2lf%%\\n';
}