Files

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

61 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2010-03-12 18:13:30 +00:00
<?php
2019-04-11 23:26:42 -05:00
require 'includes/html/graphs/common.inc.php';
2012-04-05 16:47:39 +00:00
$rrd_options .= ' -l 0 -E ';
2010-03-12 18:13:30 +00:00
$iter = '1';
2010-03-12 18:22:51 +00:00
$rrd_options .= " COMMENT:'Toner level Cur Min Max\\n'";
foreach (dbFetchRows('SELECT * FROM printer_supplies where device_id = ?', [$device['device_id']]) as $toner) {
$colour = toner2colour($toner['supply_descr'], 100 - $toner['supply_current']);
if ($colour['left'] == null) {
// FIXME generic colour function
switch ($iter) {
case '1':
$colour['left'] = '000000';
2016-08-18 20:28:22 -05:00
break;
case '2':
$colour['left'] = '008C00';
2016-08-18 20:28:22 -05:00
break;
case '3':
$colour['left'] = '4096EE';
2016-08-18 20:28:22 -05:00
break;
case '4':
$colour['left'] = '73880A';
2016-08-18 20:28:22 -05:00
break;
case '5':
$colour['left'] = 'D01F3C';
2016-08-18 20:28:22 -05:00
break;
case '6':
$colour['left'] = '36393D';
2016-08-18 20:28:22 -05:00
break;
case '7':
default:
$colour['left'] = 'FF0000';
unset($iter);
2016-08-18 20:28:22 -05:00
break;
}//end switch
}//end if
$hostname = gethostbyid($toner['device_id']);
2021-03-28 17:25:30 -05:00
$descr = \LibreNMS\Data\Store\Rrd::safeDescr(substr(str_pad($toner['supply_descr'], 16), 0, 16));
$rrd_filename = Rrd::name($device['hostname'], ['toner', $toner['supply_type'], $toner['supply_index']]);
$id = $toner['supply_id'];
$rrd_options .= " DEF:toner$id=$rrd_filename:toner:AVERAGE";
$rrd_options .= " LINE2:toner$id#" . $colour['left'] . ":'" . $descr . "'";
$rrd_options .= " GPRINT:toner$id:LAST:'%5.0lf%%'";
$rrd_options .= " GPRINT:toner$id:MIN:'%5.0lf%%'";
$rrd_options .= " GPRINT:toner$id:MAX:%5.0lf%%\l";
$iter++;
}//end foreach