1<?php 2/* 3 * LibreNMS 4 * 5 * Copyright (c) 2016 Neil Lathwood <neil@lathwood.co.uk> 6 * This program is free software: you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License as published by the 8 * Free Software Foundation, either version 3 of the License, or (at your 9 * option) any later version. Please see LICENSE.txt at the top level of 10 * the source code distribution for details. 11 */ 12 13$index = 1; 14$state_name = 'ibm-amm_BlowerState'; 15$state_descr = 'Blower '; 16$oids = [ 17 '.1.3.6.1.4.1.2.3.51.2.2.3.10.0', // BLADE-MIB::blower1State.0 18 '.1.3.6.1.4.1.2.3.51.2.2.3.11.0', // BLADE-MIB::blower2State.0 19 '.1.3.6.1.4.1.2.3.51.2.2.3.12.0', // BLADE-MIB::blower3State.0 20 '.1.3.6.1.4.1.2.3.51.2.2.3.13.0', // BLADE-MIB::blower4State.0 21]; 22/* BLADE-MIB: blower1State 23 * unknown(0), 24 * good(1), 25 * warning(2), 26 * bad(3) 27*/ 28 29foreach ($oids as $oid) { 30 $state = snmp_get($device, $oid, '-Oqv'); 31 $descr = $state_descr . $index; 32 33 if (! empty($state)) { 34 $states = [ 35 ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], 36 ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'good'], 37 ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'warning'], 38 ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'bad'], 39 ]; 40 create_state_index($state_name, $states); 41 42 discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $state, 'snmp', $index); 43 //Create Sensor To State Index 44 create_sensor_to_state_index($device, $state_name, $index); 45 $index++; 46 }//end if 47}//end foreach 48 49$index = 1; 50$state_name = 'ibm-amm_BlowerControllerState'; 51$state_descr = 'Blower Controller '; 52$oids = [ 53 '.1.3.6.1.4.1.2.3.51.2.2.3.30.0', // BLADE-MIB::blower1ControllerState.0 54 '.1.3.6.1.4.1.2.3.51.2.2.3.31.0', // BLADE-MIB::blower2ControllerState.0 55 '.1.3.6.1.4.1.2.3.51.2.2.3.32.0', // BLADE-MIB::blower3ControllerState.0 56 '.1.3.6.1.4.1.2.3.51.2.2.3.33.0', // BLADE-MIB::blower4ControllerState.0 57]; 58 59/* BLADE-MIB: blower1ControllerState 60 * operational(0), 61 * flashing(1), 62 * notPresent(2), 63 * communicationError(3), 64 * unknown(255) 65*/ 66foreach ($oids as $oid) { 67 $state = snmp_get($device, $oid, '-Oqv'); 68 $descr = $state_descr . $index; 69 70 if (is_numeric($state) && $state != 2) { 71 $states = [ 72 ['value' => 0, 'generic' => 0, 'graph' => 1, 'descr' => 'operational'], 73 ['value' => 1, 'generic' => 1, 'graph' => 1, 'descr' => 'flashing'], 74 ['value' => 2, 'generic' => -1, 'graph' => 1, 'descr' => 'notPresent'], 75 ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'communicationError'], 76 ['value' => 255, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], 77 ]; 78 create_state_index($state_name, $states); 79 80 discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $state, 'snmp', $index); 81 //Create Sensor To State Index 82 create_sensor_to_state_index($device, $state_name, $index); 83 $index++; 84 }//end if 85}//end foreach 86 87$index = 1; 88$state_name = 'ibm-amm_PowerModuleState'; 89$state_descr = 'Power Module '; 90$powerModuleStateOid = '.1.3.6.1.4.1.2.3.51.2.2.4.1.1.3'; // BLADE-MIB::powerModuleState 91$data = snmpwalk_cache_oid_num($device, $powerModuleStateOid, []); 92 93/* BLADE-MIB: powerModuleState 94 * unknown(0), 95 * good(1), 96 * warning(2), 97 * notAvailable(3), 98 * critical(4) 99*/ 100foreach ($data as $oid => $array) { 101 $state = current($array); // get the first (and only) item from the array 102 $descr = $state_descr . $index; 103 104 if (is_numeric($state) && $state != 3) { 105 $states = [ 106 ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], 107 ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'good'], 108 ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'warning'], 109 ['value' => 3, 'generic' => -1, 'graph' => 1, 'descr' => 'notAvailable'], 110 ['value' => 4, 'generic' => 2, 'graph' => 1, 'descr' => 'critical'], 111 ]; 112 create_state_index($state_name, $states); 113 114 discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $state, 'snmp', $index); 115 //Create Sensor To State Index 116 create_sensor_to_state_index($device, $state_name, $index); 117 $index++; 118 }//end if 119}//end foreach 120