1<?php 2/** 3 * compas.inc.php 4 * 5 * LibreNMS state sensor discovery module for Alpha Comp@s UPS 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <https://www.gnu.org/licenses/>. 19 * 20 * @link https://www.librenms.org 21 * @copyright 2019 Paul Parsons 22 * @author Paul Parsons <paul@cppmonkey.net> 23 */ 24$batteryTestState = snmp_get($device, 'es1dc1DataBatBatTestState.0', '-Ovqe', 'SITE-MONITORING-MIB'); 25$curOID = '.1.3.6.1.4.1.26854.3.2.1.20.1.20.1.13.3.72.0'; 26$index = 'es1dc1DataBatBatTestState'; 27if (is_numeric($batteryTestState)) { 28 //Create State Index 29 $state_name = 'es1dc1DataBatBatTestState'; 30 $states = [ 31 ['value' => 0, 'generic' => 0, 'graph' => 0, 'descr' => 'Never Tested'], 32 ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Success'], 33 ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'On Going'], 34 ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: Timeout'], 35 ['value' => 4, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: Vbus Too Low'], 36 ['value' => 5, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: Load Too Low'], 37 ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'Failed: AC Failure'], 38 ['value' => 7, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: Canceled'], 39 ['value' => 8, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: LVD Opened'], 40 ['value' => 9, 'generic' => 1, 'graph' => 0, 'descr' => 'Failed: No Battery'], 41 ]; 42 create_state_index($state_name, $states); 43 44 $descr = 'Battery Test Status'; 45 //Discover Sensors 46 discover_sensor($valid['sensor'], 'state', $device, $curOID, $index, $state_name, $descr, '1', '1', null, null, null, null, $batteryTestState); 47 //Create Sensor To State Index 48 create_sensor_to_state_index($device, $state_name, $index); 49} 50$dcMode = snmp_get($device, 'es1dc1DataSystemDCMode.0', '-Ovqe', 'SITE-MONITORING-MIB'); 51$curOID = '.1.3.6.1.4.1.26854.3.2.1.20.1.20.1.13.3.1.0'; 52$index = 'es1dc1DataSystemDCMode'; 53if (is_numeric($dcMode)) { 54 //Create State Index 55 $state_name = 'es1dc1DataSystemDCMode'; 56 $states = [ 57 ['value' => 0, 'generic' => 0, 'graph' => 0, 'descr' => 'Float'], 58 ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Equalize'], 59 ['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Battery Test'], 60 ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'AC Failure'], 61 ['value' => 5, 'generic' => 0, 'graph' => 0, 'descr' => 'Safe'], 62 ]; 63 create_state_index($state_name, $states); 64 65 $descr = 'System DC Mode'; 66 //Discover Sensors 67 discover_sensor($valid['sensor'], 'state', $device, $curOID, $index, $state_name, $descr, '1', '1', null, null, null, null, $dcMode); 68 //Create Sensor To State Index 69 create_sensor_to_state_index($device, $state_name, $index); 70} 71