Files
librenms-librenms/includes/html/graphs/device/sensor.inc.php

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

50 lines
1.6 KiB
PHP
Raw Normal View History

<?php
require 'includes/html/graphs/common.inc.php';
2015-07-13 20:10:26 +02:00
$col_w = 7 + strlen($unit);
$rrd_options .= " COMMENT:'" . str_pad($unit_long, 19) . str_pad('Cur', $col_w) . str_pad('Min', $col_w) . str_pad('Max', $col_w) . "Avg\\n'";
foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_index`', [$class, $device['device_id']]) as $index => $sensor) {
// FIXME generic colour function
switch ($index % 7) {
case 0:
$colour = 'CC0000';
2015-07-13 20:10:26 +02:00
break;
case 1:
$colour = '008C00';
2015-07-13 20:10:26 +02:00
break;
case 2:
$colour = '4096EE';
2015-07-13 20:10:26 +02:00
break;
case 3:
$colour = '73880A';
2015-07-13 20:10:26 +02:00
break;
case 4:
$colour = 'D01F3C';
2015-07-13 20:10:26 +02:00
break;
case 5:
$colour = '36393D';
2015-07-13 20:10:26 +02:00
break;
case 6:
2015-07-13 20:10:26 +02:00
default:
$colour = 'FF0084';
2015-07-13 20:10:26 +02:00
}//end switch
$sensor_descr_fixed = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($sensor['sensor_descr'], 12);
$rrd_filename = get_sensor_rrd($device, $sensor);
$rrd_options .= " DEF:sensor{$sensor['sensor_id']}=$rrd_filename:sensor:AVERAGE";
$rrd_options .= " LINE1:sensor{$sensor['sensor_id']}#$colour:'$sensor_descr_fixed'";
$rrd_options .= " GPRINT:sensor{$sensor['sensor_id']}:LAST:%5.1lf$unit";
$rrd_options .= " GPRINT:sensor{$sensor['sensor_id']}:MIN:%5.1lf$unit";
$rrd_options .= " GPRINT:sensor{$sensor['sensor_id']}:MAX:%5.1lf$unit";
$rrd_options .= " GPRINT:sensor{$sensor['sensor_id']}:AVERAGE:%5.2lf$unit\\l ";
2015-07-13 20:10:26 +02:00
$iter++;
}//end foreach