mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added new sensor - Battery Charge. Added discover and polling for APC UPSes.
This commit is contained in:
9
html/includes/graphs/device/charge.inc.php
Normal file
9
html/includes/graphs/device/charge.inc.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$class = "charge";
|
||||
$unit = "%%";
|
||||
$unit_long = "Percent";
|
||||
|
||||
include("includes/graphs/device/sensor.inc.php");
|
||||
|
||||
?>
|
29
html/includes/graphs/sensor/charge.inc.php
Normal file
29
html/includes/graphs/sensor/charge.inc.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
$scale_min = "25";
|
||||
$scale_max = "40";
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename:sensor:AVERAGE";
|
||||
$rrd_options .= " DEF:sensor_max=$rrd_filename:sensor:MAX";
|
||||
$rrd_options .= " DEF:sensor_min=$rrd_filename:sensor:MIN";
|
||||
$rrd_options .= " CDEF:sensorwarm=sensor_max,".$sensor['sensor_limit'].",GT,sensor,UNKN,IF";
|
||||
$rrd_options .= " CDEF:sensorcold=sensor_min,20,LT,sensor,UNKN,IF";
|
||||
$rrd_options .= " AREA:sensor_max#c5c5c5";
|
||||
$rrd_options .= " AREA:sensor_min#ffffffff";
|
||||
|
||||
# $rrd_options .= " AREA:sensor#bbd392";
|
||||
# $rrd_options .= " AREA:sensorwarm#FFCCCC";
|
||||
# $rrd_options .= " AREA:sensorcold#CCCCFF";
|
||||
$rrd_options .= " LINE1:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],28)."'";
|
||||
$rrd_options .= " LINE1:sensorwarm#660000";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%3.0lf%%";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%3.0lf%%\\\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
?>
|
@@ -5,6 +5,7 @@ $diskio = dbFetchCell("select count(*) from ucd_diskio WHERE device_id = ?
|
||||
$mempools = dbFetchCell("select count(*) from mempools WHERE device_id = ?", array($device['device_id']));
|
||||
$processor = dbFetchCell("select count(*) from processors WHERE device_id = ?", array($device['device_id']));
|
||||
|
||||
$charge = dbFetchCell("select count(*) from sensors WHERE sensor_class='charge' AND device_id = ?", array($device['device_id']));
|
||||
$temperatures = dbFetchCell("select count(*) from sensors WHERE sensor_class='temperature' AND device_id = ?", array($device['device_id']));
|
||||
$humidity = dbFetchCell("select count(*) from sensors WHERE sensor_class='humidity' AND device_id = ?", array($device['device_id']));
|
||||
$fans = dbFetchCell("select count(*) from sensors WHERE sensor_class='fanspeed' AND device_id = ?", array($device['device_id']));
|
||||
@@ -20,6 +21,7 @@ if ($processor) { $datas[] = 'processor'; }
|
||||
if ($mempools) { $datas[] = 'mempool'; }
|
||||
if ($storage) { $datas[] = 'storage'; }
|
||||
if ($diskio) { $datas[] = 'diskio'; }
|
||||
if ($charge) { $datas[] = 'charge'; }
|
||||
if ($temperatures) { $datas[] = 'temperature'; }
|
||||
if ($humidity) { $datas[] = 'humidity'; }
|
||||
if ($fans) { $datas[] = 'fanspeed'; }
|
||||
@@ -30,6 +32,7 @@ if ($power) { $datas[] = 'power'; }
|
||||
if ($dBm) { $datas[] = 'dbm'; }
|
||||
|
||||
$type_text['overview'] = "Overview";
|
||||
$type_text['charge'] = "Battery Charge";
|
||||
$type_text['temperature'] = "Temperature";
|
||||
$type_text['humidity'] = "Humidity";
|
||||
$type_text['mempool'] = "Memory";
|
||||
|
9
html/pages/device/health/charge.inc.php
Normal file
9
html/pages/device/health/charge.inc.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$class = "charge";
|
||||
$unit = "%";
|
||||
$graph_type = "sensor_charge";
|
||||
|
||||
include("sensors.inc.php");
|
||||
|
||||
?>
|
@@ -39,6 +39,7 @@ include("overview/storage.inc.php");
|
||||
if(is_array($entity_state['group']['c6kxbar'])) { include("overview/c6kxbar.inc.php"); }
|
||||
|
||||
include("overview/toner.inc.php");
|
||||
include("overview/sensors/charge.inc.php");
|
||||
include("overview/sensors/temperatures.inc.php");
|
||||
include("overview/sensors/humidity.inc.php");
|
||||
include("overview/sensors/fanspeeds.inc.php");
|
||||
|
10
html/pages/device/overview/sensors/charge.inc.php
Normal file
10
html/pages/device/overview/sensors/charge.inc.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$graph_type = "sensor_charge";
|
||||
$sensor_class = "charge";
|
||||
$sensor_unit = "%";
|
||||
$sensor_type = "Battery Charge";
|
||||
|
||||
include('pages/device/overview/generic/sensor.inc.php');
|
||||
|
||||
?>
|
@@ -2,6 +2,7 @@
|
||||
|
||||
$datas = array('mempool','processor','storage');
|
||||
if ($used_sensors['temperature']) $datas[] = 'temperature';
|
||||
if ($used_sensors['charge']) $datas[] = 'charge';
|
||||
if ($used_sensors['humidity']) $datas[] = 'humidity';
|
||||
if ($used_sensors['fanspeed']) $datas[] = 'fanspeed';
|
||||
if ($used_sensors['voltage']) $datas[] = 'voltage';
|
||||
@@ -13,6 +14,7 @@ if ($used_sensors['dBm']) $datas[] = 'dBm';
|
||||
// FIXME generalize -> static-config ?
|
||||
$type_text['overview'] = "Overview";
|
||||
$type_text['temperature'] = "Temperature";
|
||||
$type_text['charge'] = "Battery Charge";
|
||||
$type_text['humidity'] = "Humidity";
|
||||
$type_text['mempool'] = "Memory";
|
||||
$type_text['storage'] = "Disk Usage";
|
||||
|
9
html/pages/health/charge.inc.php
Normal file
9
html/pages/health/charge.inc.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$graph_type = "sensor_charge";
|
||||
$unit = "%";
|
||||
$class = "charge";
|
||||
|
||||
include("pages/health/sensors.inc.php");
|
||||
|
||||
?>
|
@@ -563,6 +563,7 @@ $config['discovery_modules']['libvirt-vminfo'] = 1;
|
||||
$config['discovery_modules']['toner'] = 1;
|
||||
$config['discovery_modules']['ucd-diskio'] = 1;
|
||||
$config['discovery_modules']['services'] = 1;
|
||||
$config['discovery_modules']['charge'] = 1;
|
||||
|
||||
$config['modules_compat']['rfc1628']['liebert'] = 1;
|
||||
$config['modules_compat']['rfc1628']['netmanplus'] = 1;
|
||||
|
@@ -1102,6 +1102,9 @@ $config['graph_types']['device']['storage']['descr'] = 'Filesystem Usage';
|
||||
$config['graph_types']['device']['temperature']['section'] = 'system';
|
||||
$config['graph_types']['device']['temperature']['order'] = '0';
|
||||
$config['graph_types']['device']['temperature']['descr'] = 'temperature';
|
||||
$config['graph_types']['device']['charge']['section'] = 'system';
|
||||
$config['graph_types']['device']['charge']['order'] = '0';
|
||||
$config['graph_types']['device']['charge']['descr'] = 'Battery Charge';
|
||||
$config['graph_types']['device']['ucd_cpu']['section'] = 'system';
|
||||
$config['graph_types']['device']['ucd_cpu']['order'] = '0';
|
||||
$config['graph_types']['device']['ucd_cpu']['descr'] = 'Detailed Processor Usage';
|
||||
|
16
includes/discovery/charge.inc.php
Executable file
16
includes/discovery/charge.inc.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
echo("Bettery Charge: ");
|
||||
|
||||
// Include all discovery modules
|
||||
|
||||
$include_dir = "includes/discovery/charge";
|
||||
include("includes/include-dir.inc.php");
|
||||
|
||||
if ($debug) { print_r($valid['sensor']['charge']); }
|
||||
|
||||
check_valid_sensors($device, 'charge', $valid['sensor']);
|
||||
|
||||
echo("\n");
|
||||
|
||||
?>
|
29
includes/discovery/charge/apc.inc.php
Normal file
29
includes/discovery/charge/apc.inc.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] == "apc")
|
||||
{
|
||||
$oids = snmp_get($device, "1.3.6.1.4.1.318.1.1.1.2.3.1.0", "-OsqnU", "");
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
|
||||
if ($oids)
|
||||
{
|
||||
echo("APC UPS Battery Charge");
|
||||
$type = "apc";
|
||||
list($oid,$current) = explode(' ',$oids);
|
||||
|
||||
$precision = 10;
|
||||
$sensorType = "apc";
|
||||
$current_oid = "1.3.6.1.4.1.318.1.1.1.2.3.1.0";
|
||||
$index = 0;
|
||||
$current_val = $current / $precision;
|
||||
$limit = 100;
|
||||
$lowlimit = 0;
|
||||
$warnlimit = 10;
|
||||
$descr = "Battery Charge";
|
||||
|
||||
discover_sensor($valid['sensor'], 'charge', $device, $current_oid, $index, $sensorType, $descr, $precision, '1', $lowlimit, $warnlimit, NULL, $limit , $current_val);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@@ -17,5 +17,6 @@ include("includes/discovery/frequencies.inc.php");
|
||||
include("includes/discovery/current.inc.php");
|
||||
include("includes/discovery/power.inc.php");
|
||||
include("includes/discovery/fanspeeds.inc.php");
|
||||
include("includes/discovery/charge.inc.php");
|
||||
|
||||
?>
|
||||
|
@@ -20,7 +20,8 @@ $supported_sensors = array('current' => 'A',
|
||||
'power' => 'W',
|
||||
'voltage' => 'V',
|
||||
'temperature' => 'C',
|
||||
'dbm' => 'dBm');
|
||||
'dbm' => 'dBm',
|
||||
'charge' => '%');
|
||||
|
||||
foreach ($supported_sensors as $sensor_type => $sensor_unit)
|
||||
{
|
||||
|
Reference in New Issue
Block a user