From 1e6755c4d52a214a547d7f9c317316a8aa6f54d1 Mon Sep 17 00:00:00 2001 From: Calvario Date: Thu, 11 Jun 2015 15:20:09 +0200 Subject: [PATCH 1/2] UPS Support for Synology Ready but need "load" sensors. --- includes/discovery/charge/dsm.inc.php | 33 ++++++++++++++ includes/discovery/power/dsm.inc.php | 33 ++++++++++++++ includes/discovery/voltages/dsm.inc.php | 57 +++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 includes/discovery/charge/dsm.inc.php create mode 100644 includes/discovery/power/dsm.inc.php create mode 100644 includes/discovery/voltages/dsm.inc.php diff --git a/includes/discovery/charge/dsm.inc.php b/includes/discovery/charge/dsm.inc.php new file mode 100644 index 000000000..45f163b2a --- /dev/null +++ b/includes/discovery/charge/dsm.inc.php @@ -0,0 +1,33 @@ + + * + * 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 + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os'] == "dsm") { + + 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 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); + } +} \ No newline at end of file diff --git a/includes/discovery/power/dsm.inc.php b/includes/discovery/power/dsm.inc.php new file mode 100644 index 000000000..7a50ac758 --- /dev/null +++ b/includes/discovery/power/dsm.inc.php @@ -0,0 +1,33 @@ + + * + * 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 + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os'] == "dsm") { + + echo "DSM UPS Power"; + + // 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 Info Real Power Nominal, example return : SNMPv2-SMI::enterprises.6574.4.2.21.2.0 = Opaque: Float: 540.000000 + $ups_real_power_nominal_oid = '.1.3.6.1.4.1.6574.4.2.21.2.0'; + $ups_real_power_nominal = snmp_get($device, $ups_real_power_nominal_oid, "-Oqv"); + if (is_numeric($ups_real_power_nominal)) { + discover_sensor($valid['sensor'], 'power', $device, $ups_real_power_nominal_oid, 'UPSRealPowerNominal', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Real Power Nominal', '1', '1', NULL, NULL, NULL, NULL, $ups_real_power_nominal); + } +} \ No newline at end of file diff --git a/includes/discovery/voltages/dsm.inc.php b/includes/discovery/voltages/dsm.inc.php new file mode 100644 index 000000000..f5f76bba2 --- /dev/null +++ b/includes/discovery/voltages/dsm.inc.php @@ -0,0 +1,57 @@ + + * + * 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 + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os'] == "dsm") { + + echo "DSM UPS Voltage"; + + // 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 Input Voltage Value, example return : SNMPv2-SMI::enterprises.6574.4.4.1.1.0 = Opaque: Float: 234.000000 + $ups_input_voltage_oid = '.1.3.6.1.4.1.6574.4.4.1.1.0'; + $ups_input_voltage = snmp_get($device, $ups_input_voltage_oid, "-Oqv"); + if (is_numeric($ups_input_voltage)) { + discover_sensor($valid['sensor'], 'voltage', $device, $ups_input_voltage_oid, 'UPSInputVoltageValue', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Input Voltage Value', '1', '1', NULL, NULL, NULL, NULL, $ups_input_voltage); + } + + + // UPS Input Voltage Nominal, example return : SNMPv2-SMI::enterprises.6574.4.4.1.4.0 = Opaque: Float: 230.000000 + $ups_input_voltage_nominal_oid = '.1.3.6.1.4.1.6574.4.4.1.4.0'; + $ups_input_voltage_nominal = snmp_get($device, $ups_input_voltage_nominal_oid, "-Oqv"); + if (is_numeric($ups_input_voltage_nominal)) { + discover_sensor($valid['sensor'], 'voltage', $device, $ups_input_voltage_nominal_oid, 'UPSInputVoltageNominal', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Input Voltage Nominal', '1', '1', NULL, NULL, NULL, NULL, $ups_input_voltage_nominal); + } + + + // UPS Battery Voltage Value, example return : SNMPv2-SMI::enterprises.6574.4.3.2.1.0 = Opaque: Float: 27.000000 + $ups_battery_voltage_oid = '.1.3.6.1.4.1.6574.4.3.2.1.0'; + $ups_battery_voltage = snmp_get($device, $ups_battery_voltage_oid, "-Oqv"); + if (is_numeric($ups_battery_voltage)) { + discover_sensor($valid['sensor'], 'voltage', $device, $ups_battery_voltage_oid, 'UPSBatteryVoltage', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Battery Voltage', '1', '1', NULL, NULL, NULL, NULL, $ups_battery_voltage); + } + + + // UPS Battery Voltage Nominal, example return : SNMPv2-SMI::enterprises.6574.4.3.2.2.0 = Opaque: Float: 24.000000 + $ups_battery_voltage_nominal_oid = '.1.3.6.1.4.1.6574.4.3.2.2.0'; + $ups_battery_voltage_nominal = snmp_get($device, $ups_battery_voltage_nominal_oid, "-Oqv"); + if (is_numeric($ups_battery_voltage_nominal)) { + discover_sensor($valid['sensor'], 'voltage', $device, $ups_battery_voltage_nominal_oid, 'SystemStatus', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Battery Voltage Nominal', '1', '1', NULL, NULL, NULL, NULL, $ups_battery_voltage_nominal); + } +} \ No newline at end of file From ced0804ba5665fc36732aba1a16e4e20871f799e Mon Sep 17 00:00:00 2001 From: Calvario Date: Thu, 11 Jun 2015 15:53:46 +0200 Subject: [PATCH 2/2] New line correction --- includes/discovery/charge/dsm.inc.php | 2 +- includes/discovery/power/dsm.inc.php | 2 +- includes/discovery/voltages/dsm.inc.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/discovery/charge/dsm.inc.php b/includes/discovery/charge/dsm.inc.php index 45f163b2a..f5faa1639 100644 --- a/includes/discovery/charge/dsm.inc.php +++ b/includes/discovery/charge/dsm.inc.php @@ -30,4 +30,4 @@ if ($device['os'] == "dsm") { 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); } -} \ No newline at end of file +} diff --git a/includes/discovery/power/dsm.inc.php b/includes/discovery/power/dsm.inc.php index 7a50ac758..fd99baba5 100644 --- a/includes/discovery/power/dsm.inc.php +++ b/includes/discovery/power/dsm.inc.php @@ -30,4 +30,4 @@ if ($device['os'] == "dsm") { if (is_numeric($ups_real_power_nominal)) { discover_sensor($valid['sensor'], 'power', $device, $ups_real_power_nominal_oid, 'UPSRealPowerNominal', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Real Power Nominal', '1', '1', NULL, NULL, NULL, NULL, $ups_real_power_nominal); } -} \ No newline at end of file +} diff --git a/includes/discovery/voltages/dsm.inc.php b/includes/discovery/voltages/dsm.inc.php index f5f76bba2..f44878216 100644 --- a/includes/discovery/voltages/dsm.inc.php +++ b/includes/discovery/voltages/dsm.inc.php @@ -54,4 +54,4 @@ if ($device['os'] == "dsm") { if (is_numeric($ups_battery_voltage_nominal)) { discover_sensor($valid['sensor'], 'voltage', $device, $ups_battery_voltage_nominal_oid, 'SystemStatus', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Battery Voltage Nominal', '1', '1', NULL, NULL, NULL, NULL, $ups_battery_voltage_nominal); } -} \ No newline at end of file +}