From 410268adfa9546177a5dad828aa13aa1cb5e01d2 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 4 Dec 2024 23:11:01 -0600 Subject: [PATCH] IBM AMM sensors to yaml --- includes/definitions/discovery/ibm-amm.yaml | 142 ++++++++++++++++++ .../sensors/fanspeed/ibm-amm.inc.php | 29 ---- .../discovery/sensors/state/ibm-amm.inc.php | 119 --------------- .../sensors/temperature/ibm-amm.inc.php | 45 ------ 4 files changed, 142 insertions(+), 193 deletions(-) create mode 100644 includes/definitions/discovery/ibm-amm.yaml delete mode 100644 includes/discovery/sensors/fanspeed/ibm-amm.inc.php delete mode 100644 includes/discovery/sensors/state/ibm-amm.inc.php delete mode 100644 includes/discovery/sensors/temperature/ibm-amm.inc.php diff --git a/includes/definitions/discovery/ibm-amm.yaml b/includes/definitions/discovery/ibm-amm.yaml new file mode 100644 index 000000000000..982b09e3d487 --- /dev/null +++ b/includes/definitions/discovery/ibm-amm.yaml @@ -0,0 +1,142 @@ +modules: + sensors: + temperature: + data: + - + oid: BLADE-MIB::mmTemp + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.1.1.2.{{ $index }}' + index: 'mmTemp' + descr: Management module temperature + - + oid: BLADE-MIB::frontPanelTemp + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.1.5.1.{{ $index }}' + index: 'frontPanelTemp' + descr: Front panel temperature + fanspeed: + data: + - + oid: BLADE-MIB:blower1speedRPM + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.3.20.{{ $index }}' + index: 'blower1speedRPM' + descr: Blower 1 + - + oid: BLADE-MIB:blower2speedRPM + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.3.21.{{ $index }}' + index: 'blower2speedRPM' + descr: Blower 2 + - + oid: BLADE-MIB:blower3speedRPM + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.3.22.{{ $index }}' + index: 'blower3speedRPM' + descr: Blower 3 + - + oid: BLADE-MIB:blower4speedRPM + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.3.23.{{ $index }}' + index: 'blower4speedRPM' + descr: Blower 4 + state: + data: + - + oid: BLADE-MIB::blower1State + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.3.10.{{ $index }}' + index: 'blower1State' + descr: Blower 1 + state_name: ibm-amm_BlowerState + states: + - { value: 0, generic: 3, graph: 0, descr: 'unknown' } + - { value: 1, generic: 0, graph: 1, descr: 'good' } + - { value: 2, generic: 1, graph: 1, descr: 'warning' } + - { value: 3, generic: 2, graph: 1, descr: 'bad' } + - + oid: BLADE-MIB::blower2State + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.3.11.{{ $index }}' + index: 'blower2State' + descr: Blower 2 + state_name: ibm-amm_BlowerState + states: + - { value: 0, generic: 3, graph: 0, descr: 'unknown' } + - { value: 1, generic: 0, graph: 1, descr: 'good' } + - { value: 2, generic: 1, graph: 1, descr: 'warning' } + - { value: 3, generic: 2, graph: 1, descr: 'bad' } + - + oid: BLADE-MIB::blower3State + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.3.12.{{ $index }}' + index: 'blower3State' + descr: Blower 3 + state_name: ibm-amm_BlowerState + states: + - { value: 0, generic: 3, graph: 0, descr: 'unknown' } + - { value: 1, generic: 0, graph: 1, descr: 'good' } + - { value: 2, generic: 1, graph: 1, descr: 'warning' } + - { value: 3, generic: 2, graph: 1, descr: 'bad' } + - + oid: BLADE-MIB::blower4State + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.3.13.{{ $index }}' + index: 'blower4State' + descr: Blower 4 + state_name: ibm-amm_BlowerState + states: + - { value: 0, generic: 3, graph: 0, descr: 'unknown' } + - { value: 1, generic: 0, graph: 1, descr: 'good' } + - { value: 2, generic: 1, graph: 1, descr: 'warning' } + - { value: 3, generic: 2, graph: 1, descr: 'bad' } + - + oid: BLADE-MIB::blower1ControllerState + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.3.30.{{ $index }}' + index: 'blower1ControllerState' + descr: Blower Controller 1 + state_name: ibm-amm_BlowerControllerState + states: + - { value: 0, generic: 0, graph: 1, descr: 'operational' } + - { value: 1, generic: 1, graph: 1, descr: 'flashing' } + - { value: 2, generic: -1, graph: 1, descr: 'notPresent' } + - { value: 3, generic: 2, graph: 1, descr: 'communicationError' } + - { value: 255, generic: 3, graph: 0, descr: 'unknown' } + - + oid: BLADE-MIB::blower2ControllerState + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.3.31.{{ $index }}' + index: 'blower2ControllerState' + descr: Blower Controller 2 + state_name: ibm-amm_BlowerControllerState + states: + - { value: 0, generic: 0, graph: 1, descr: 'operational' } + - { value: 1, generic: 1, graph: 1, descr: 'flashing' } + - { value: 2, generic: -1, graph: 1, descr: 'notPresent' } + - { value: 3, generic: 2, graph: 1, descr: 'communicationError' } + - { value: 255, generic: 3, graph: 0, descr: 'unknown' } + - + oid: BLADE-MIB::blower3ControllerState + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.3.32.{{ $index }}' + index: 'blower3ControllerState' + descr: Blower Controller 3 + state_name: ibm-amm_BlowerControllerState + states: + - { value: 0, generic: 0, graph: 1, descr: 'operational' } + - { value: 1, generic: 1, graph: 1, descr: 'flashing' } + - { value: 2, generic: -1, graph: 1, descr: 'notPresent' } + - { value: 3, generic: 2, graph: 1, descr: 'communicationError' } + - { value: 255, generic: 3, graph: 0, descr: 'unknown' } + - + oid: BLADE-MIB::blower4ControllerState + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.3.33.{{ $index }}' + index: 'blower4ControllerState' + descr: Blower Controller 4 + state_name: ibm-amm_BlowerControllerState + states: + - { value: 0, generic: 0, graph: 1, descr: 'operational' } + - { value: 1, generic: 1, graph: 1, descr: 'flashing' } + - { value: 2, generic: -1, graph: 1, descr: 'notPresent' } + - { value: 3, generic: 2, graph: 1, descr: 'communicationError' } + - { value: 255, generic: 3, graph: 0, descr: 'unknown' } + - + oid: BLADE-MIB::powerModuleState + num_oid: '.1.3.6.1.4.1.2.3.51.2.2.4.1.1.3.{{ $index }}' + index: 'powerModuleState.{{ $index }}' + descr: 'Power Module {{ $index }}' + state_name: ibm-amm_PowerModuleState + states: + - { value: 0, generic: 3, graph: 0, descr: 'unknown' } + - { value: 1, generic: 0, graph: 1, descr: 'good' } + - { value: 2, generic: 1, graph: 1, descr: 'warning' } + - { value: 3, generic: -1, graph: 1, descr: 'notAvailable' } + - { value: 4, generic: 2, graph: 1, descr: 'critical' } diff --git a/includes/discovery/sensors/fanspeed/ibm-amm.inc.php b/includes/discovery/sensors/fanspeed/ibm-amm.inc.php deleted file mode 100644 index 00afdbe1e9ac..000000000000 --- a/includes/discovery/sensors/fanspeed/ibm-amm.inc.php +++ /dev/null @@ -1,29 +0,0 @@ - - * 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. - */ - -$descr_prefix = 'Blower '; -$oids = [ - '.1.3.6.1.4.1.2.3.51.2.2.3.20.0', // BLADE-MIB:blower1speedRPM - '.1.3.6.1.4.1.2.3.51.2.2.3.21.0', // BLADE-MIB:blower2speedRPM - '.1.3.6.1.4.1.2.3.51.2.2.3.22.0', // BLADE-MIB:blower3speedRPM - '.1.3.6.1.4.1.2.3.51.2.2.3.23.0', // BLADE-MIB:blower4speedRPM -]; - -echo 'BLADE-MIB '; -foreach ($oids as $index => $oid) { - $value = trim(snmp_get($device, $oid, '-Oqv'), '"'); - - if (is_numeric($value)) { - $descr = $descr_prefix . ($index + 1); - discover_sensor(null, 'fanspeed', $device, $oid, $index, 'snmp', $descr, 1, 1, null, null, null, null, $value); - } -} diff --git a/includes/discovery/sensors/state/ibm-amm.inc.php b/includes/discovery/sensors/state/ibm-amm.inc.php deleted file mode 100644 index 1bfd2e376cc1..000000000000 --- a/includes/discovery/sensors/state/ibm-amm.inc.php +++ /dev/null @@ -1,119 +0,0 @@ - - * 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. - */ - -$index = 1; -$state_name = 'ibm-amm_BlowerState'; -$state_descr = 'Blower '; -$oids = [ - '.1.3.6.1.4.1.2.3.51.2.2.3.10.0', // BLADE-MIB::blower1State.0 - '.1.3.6.1.4.1.2.3.51.2.2.3.11.0', // BLADE-MIB::blower2State.0 - '.1.3.6.1.4.1.2.3.51.2.2.3.12.0', // BLADE-MIB::blower3State.0 - '.1.3.6.1.4.1.2.3.51.2.2.3.13.0', // BLADE-MIB::blower4State.0 -]; -/* BLADE-MIB: blower1State - * unknown(0), - * good(1), - * warning(2), - * bad(3) -*/ - -foreach ($oids as $oid) { - $state = snmp_get($device, $oid, '-Oqv'); - $descr = $state_descr . $index; - - if (! empty($state)) { - $states = [ - ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], - ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'good'], - ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'warning'], - ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'bad'], - ]; - create_state_index($state_name, $states); - - discover_sensor(null, 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $state, 'snmp', $index); - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); - $index++; - }//end if -}//end foreach - -$index = 1; -$state_name = 'ibm-amm_BlowerControllerState'; -$state_descr = 'Blower Controller '; -$oids = [ - '.1.3.6.1.4.1.2.3.51.2.2.3.30.0', // BLADE-MIB::blower1ControllerState.0 - '.1.3.6.1.4.1.2.3.51.2.2.3.31.0', // BLADE-MIB::blower2ControllerState.0 - '.1.3.6.1.4.1.2.3.51.2.2.3.32.0', // BLADE-MIB::blower3ControllerState.0 - '.1.3.6.1.4.1.2.3.51.2.2.3.33.0', // BLADE-MIB::blower4ControllerState.0 -]; - -/* BLADE-MIB: blower1ControllerState - * operational(0), - * flashing(1), - * notPresent(2), - * communicationError(3), - * unknown(255) -*/ -foreach ($oids as $oid) { - $state = snmp_get($device, $oid, '-Oqv'); - $descr = $state_descr . $index; - - if (is_numeric($state) && $state != 2) { - $states = [ - ['value' => 0, 'generic' => 0, 'graph' => 1, 'descr' => 'operational'], - ['value' => 1, 'generic' => 1, 'graph' => 1, 'descr' => 'flashing'], - ['value' => 2, 'generic' => -1, 'graph' => 1, 'descr' => 'notPresent'], - ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'communicationError'], - ['value' => 255, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], - ]; - create_state_index($state_name, $states); - - discover_sensor(null, 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $state, 'snmp', $index); - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); - $index++; - }//end if -}//end foreach - -$index = 1; -$state_name = 'ibm-amm_PowerModuleState'; -$state_descr = 'Power Module '; -$powerModuleStateOid = '.1.3.6.1.4.1.2.3.51.2.2.4.1.1.3'; // BLADE-MIB::powerModuleState -$data = snmpwalk_cache_oid_num($device, $powerModuleStateOid, []); - -/* BLADE-MIB: powerModuleState - * unknown(0), - * good(1), - * warning(2), - * notAvailable(3), - * critical(4) -*/ -foreach ($data as $oid => $array) { - $state = current($array); // get the first (and only) item from the array - $descr = $state_descr . $index; - - if (is_numeric($state) && $state != 3) { - $states = [ - ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], - ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'good'], - ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'warning'], - ['value' => 3, 'generic' => -1, 'graph' => 1, 'descr' => 'notAvailable'], - ['value' => 4, 'generic' => 2, 'graph' => 1, 'descr' => 'critical'], - ]; - create_state_index($state_name, $states); - - discover_sensor(null, 'state', $device, $oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $state, 'snmp', $index); - //Create Sensor To State Index - create_sensor_to_state_index($device, $state_name, $index); - $index++; - }//end if -}//end foreach diff --git a/includes/discovery/sensors/temperature/ibm-amm.inc.php b/includes/discovery/sensors/temperature/ibm-amm.inc.php deleted file mode 100644 index a7fb5e39e8f2..000000000000 --- a/includes/discovery/sensors/temperature/ibm-amm.inc.php +++ /dev/null @@ -1,45 +0,0 @@ - - * 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. - */ - -$oid = '.1.3.6.1.4.1.2.3.51.2.2.1.1.2.0'; // BLADE-MIB::mmTemp.0 -$mmtemp = snmp_get($device, $oid, '-Oqv'); - -preg_match('/[\d\.]+/', $mmtemp, $temp_response); -if (! empty($temp_response[0])) { - $mmtemp = $temp_response[0]; -} - -d_echo($mmtemp); - -if (! empty($mmtemp)) { - $descr = 'Management module temperature'; - $divisor = 1; - $current = $mmtemp; - discover_sensor(null, 'temperature', $device, $oid, $oid, 'ibm-amm', $descr, $divisor, '1', null, null, null, null, $current); -} - -$oid = '.1.3.6.1.4.1.2.3.51.2.2.1.5.1.0'; // BLADE-MIB::frontPanelTemp.0 -$fptemp = snmp_get($device, $oid, '-Oqv'); - -preg_match('/[\d\.]+/', $fptemp, $temp_response); -if (! empty($temp_response[0])) { - $fptemp = $temp_response[0]; -} - -d_echo($fptemp); - -if (! empty($fptemp)) { - $descr = 'Front panel temperature'; - $divisor = 1; - $current = $fptemp; - discover_sensor(null, 'temperature', $device, $oid, $oid, 'ibm-amm', $descr, $divisor, '1', null, null, null, null, $current); -}