refactor: Tidy up sensor discovery (#5550)

* refactor: Tidy up sensor discovery

* more files

* removed uneeded files

* updated array check

* updates for linux/supermicro

* small changes

* Update linux.inc.php

* Add supermicro temps back to linux.inc.php

* No need for is_file on rfc1628.inc.php, it exists

* Revert rfc1628 change

* Fix whitespace...

* rebased

* fixed $valid data not being passed to new sensors() function
This commit is contained in:
Neil Lathwood
2017-02-03 12:39:38 +00:00
committed by Tony Murray
parent 008af4cea0
commit d4e8c54516
252 changed files with 6669 additions and 7323 deletions

View File

@@ -1,9 +1,8 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2015 Steve Calv<6C>rio <https://github.com/Calvario/>
* Copyright (c) 2015 Steve Calv<6C>rio <https://github.com/Calvario/>
*
* 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
@@ -12,21 +11,19 @@
* the source code distribution for details.
*/
if ($device['os'] == 'dsm') {
echo 'DSM UPS Charge';
echo 'DSM UPS Charge';
// UPS Device Manufacturer, example return : SNMPv2-SMI::enterprises.6574.4.1.2.0 = STRING: "American Power Conversion"
$ups_device_manufacturer_oid = '.1.3.6.1.4.1.6574.4.1.2.0';
$ups_device_manufacturer = str_replace('"', '', snmp_get($device, $ups_device_manufacturer_oid, '-Oqv'));
// UPS Device Model, example return : SNMPv2-SMI::enterprises.6574.4.1.1.0 = STRING: "Back-UPS RS 900G"
$ups_device_model_oid = '.1.3.6.1.4.1.6574.4.1.1.0';
$ups_device_model = str_replace('"', '', snmp_get($device, $ups_device_model_oid, '-Oqv'));
// UPS Device Manufacturer, example return : SNMPv2-SMI::enterprises.6574.4.1.2.0 = STRING: "American Power Conversion"
$ups_device_manufacturer_oid = '.1.3.6.1.4.1.6574.4.1.2.0';
$ups_device_manufacturer = str_replace('"', '', snmp_get($device, $ups_device_manufacturer_oid, '-Oqv'));
// UPS Device Model, example return : SNMPv2-SMI::enterprises.6574.4.1.1.0 = STRING: "Back-UPS RS 900G"
$ups_device_model_oid = '.1.3.6.1.4.1.6574.4.1.1.0';
$ups_device_model = str_replace('"', '', snmp_get($device, $ups_device_model_oid, '-Oqv'));
// UPS Battery Charge Value, example return : SNMPv2-SMI::enterprises.6574.4.3.1.1.0 = Opaque: Float: 100.000000
$ups_charge_oid = '.1.3.6.1.4.1.6574.4.3.1.1.0';
$ups_charge = snmp_get($device, $ups_charge_oid, '-Oqv');
if (is_numeric($ups_charge)) {
discover_sensor($valid['sensor'], 'charge', $device, $ups_charge_oid, 'UPSChargeValue', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Charge Value', '1', '1', 0, 10, null, 100, $ups_charge);
}
// UPS Battery Charge Value, example return : SNMPv2-SMI::enterprises.6574.4.3.1.1.0 = Opaque: Float: 100.000000
$ups_charge_oid = '.1.3.6.1.4.1.6574.4.3.1.1.0';
$ups_charge = snmp_get($device, $ups_charge_oid, '-Oqv');
if (is_numeric($ups_charge)) {
discover_sensor($valid['sensor'], 'charge', $device, $ups_charge_oid, 'UPSChargeValue', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Charge Value', '1', '1', 0, 10, null, 100, $ups_charge);
}