mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Clean up ibm-amm sensors
Add power module state Correct state indexes Use numeric oids, but document named oids
This commit is contained in:
@@ -12,26 +12,22 @@
|
|||||||
|
|
||||||
if ($device['os'] == 'ibm-amm') {
|
if ($device['os'] == 'ibm-amm') {
|
||||||
|
|
||||||
$oids = array('blower1speedRPM', 'blower2speedRPM', 'blower3speedRPM', 'blower4speedRPM');
|
$descr_prefix = 'Blower ';
|
||||||
d_echo($oids."\n");
|
$oids = array(
|
||||||
if (!empty($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 ';
|
echo 'BLADE-MIB ';
|
||||||
foreach ($oids as $index => $data) {
|
foreach ($oids as $index => $oid) {
|
||||||
|
$value = trim(snmp_get($device, $oid, '-Oqv'), '"');
|
||||||
if (!empty($data)) {
|
|
||||||
$value = trim(snmp_get($device, $data.'.0', '-Oqv', 'BLADE-MIB'), '"');
|
|
||||||
|
|
||||||
if (is_numeric($value)) {
|
if (is_numeric($value)) {
|
||||||
$oid = 'BLADE-MIB::' . $data . '.0';
|
$descr = $descr_prefix . ($index + 1);
|
||||||
$descr = $data;
|
|
||||||
discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, 'snmp', $descr, 1, 1, null, null, null, null, $value);
|
discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, 'snmp', $descr, 1, 1, null, null, null, null, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,16 +13,25 @@
|
|||||||
if ($device['os'] == 'ibm-amm') {
|
if ($device['os'] == 'ibm-amm') {
|
||||||
|
|
||||||
$index = 1;
|
$index = 1;
|
||||||
|
$state_name = 'ibm-amm_BlowerState';
|
||||||
|
$state_descr = 'Blower ';
|
||||||
$oids = array(
|
$oids = array(
|
||||||
'blower1State' => '.1.3.6.1.4.1.2.3.51.2.2.3.10.0',
|
'.1.3.6.1.4.1.2.3.51.2.2.3.10.0', // BLADE-MIB::blower1State.0
|
||||||
'blower2State' => '.1.3.6.1.4.1.2.3.51.2.2.3.11.0',
|
'.1.3.6.1.4.1.2.3.51.2.2.3.11.0', // BLADE-MIB::blower2State.0
|
||||||
'blower3State' => '.1.3.6.1.4.1.2.3.51.2.2.3.12.0',
|
'.1.3.6.1.4.1.2.3.51.2.2.3.12.0', // BLADE-MIB::blower3State.0
|
||||||
'blower4State' => '.1.3.6.1.4.1.2.3.51.2.2.3.13.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 $state_name => $oid) {
|
foreach ($oids as $oid) {
|
||||||
|
|
||||||
$state = snmp_get($device, $oid, '-Oqv');
|
$state = snmp_get($device, $oid, '-Oqv');
|
||||||
|
$descr = $state_descr . $index;
|
||||||
|
|
||||||
if (!empty($state)) {
|
if (!empty($state)) {
|
||||||
|
|
||||||
$state_index_id = create_state_index($state_name);
|
$state_index_id = create_state_index($state_name);
|
||||||
@@ -49,7 +58,7 @@ if ($device['os'] == 'ibm-amm') {
|
|||||||
|
|
||||||
}//end if
|
}//end if
|
||||||
|
|
||||||
discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $state_name, '1', '1', null, null, null, null, $state, 'snmp', $index);
|
discover_sensor($valid['sensor'], '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
|
||||||
create_sensor_to_state_index($device, $state_name, $index);
|
create_sensor_to_state_index($device, $state_name, $index);
|
||||||
$index++;
|
$index++;
|
||||||
@@ -59,15 +68,25 @@ if ($device['os'] == 'ibm-amm') {
|
|||||||
}//end foreach
|
}//end foreach
|
||||||
|
|
||||||
$index = 1;
|
$index = 1;
|
||||||
|
$state_name = 'ibm-amm_BlowerControllerState';
|
||||||
|
$state_descr = 'Blower Controller ';
|
||||||
$oids = array(
|
$oids = array(
|
||||||
'blower1ControllerState' => '.1.3.6.1.4.1.2.3.51.2.2.3.30.0',
|
'.1.3.6.1.4.1.2.3.51.2.2.3.30.0', // BLADE-MIB::blower1ControllerState.0
|
||||||
'blower2ControllerState' => '.1.3.6.1.4.1.2.3.51.2.2.3.31.0',
|
'.1.3.6.1.4.1.2.3.51.2.2.3.31.0', // BLADE-MIB::blower2ControllerState.0
|
||||||
'blower3ControllerState' => '.1.3.6.1.4.1.2.3.51.2.2.3.32.0',
|
'.1.3.6.1.4.1.2.3.51.2.2.3.32.0', // BLADE-MIB::blower3ControllerState.0
|
||||||
'blower4ControllerState' => '.1.3.6.1.4.1.2.3.51.2.2.3.33.0');
|
'.1.3.6.1.4.1.2.3.51.2.2.3.33.0', // BLADE-MIB::blower4ControllerState.0
|
||||||
|
);
|
||||||
foreach ($oids as $state_name => $oid) {
|
|
||||||
|
|
||||||
|
/* BLADE-MIB: blower1ControllerState
|
||||||
|
* operational(0),
|
||||||
|
* flashing(1),
|
||||||
|
* notPresent(2),
|
||||||
|
* communicationError(3),
|
||||||
|
* unknown(255)
|
||||||
|
*/
|
||||||
|
foreach ($oids as $oid) {
|
||||||
$state = snmp_get($device, $oid, '-Oqv');
|
$state = snmp_get($device, $oid, '-Oqv');
|
||||||
|
$descr = $state_descr . $index;
|
||||||
|
|
||||||
if (is_numeric($state) && $state != 2) {
|
if (is_numeric($state) && $state != 2) {
|
||||||
|
|
||||||
@@ -76,11 +95,11 @@ if ($device['os'] == 'ibm-amm') {
|
|||||||
if ($state_index_id) {
|
if ($state_index_id) {
|
||||||
|
|
||||||
$states = array(
|
$states = array(
|
||||||
array($state_index_id,'operational',0,0,0),
|
array($state_index_id, 'operational', 1, 0, 0),
|
||||||
array($state_index_id, 'flashing', 1, 1, 1),
|
array($state_index_id, 'flashing', 1, 1, 1),
|
||||||
array($state_index_id,'notPresent',1,2,2),
|
array($state_index_id, 'notPresent', 1, 2, -1),
|
||||||
array($state_index_id, 'communicationError', 1, 3, 2),
|
array($state_index_id, 'communicationError', 1, 3, 2),
|
||||||
array($state_index_id,'unknown',1,4,2),
|
array($state_index_id, 'unknown', 0, 255, 3),
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($states as $value) {
|
foreach($states as $value) {
|
||||||
@@ -96,7 +115,7 @@ if ($device['os'] == 'ibm-amm') {
|
|||||||
|
|
||||||
}//end if
|
}//end if
|
||||||
|
|
||||||
discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $state_name, '1', '1', null, null, null, null, $state, 'snmp', $index);
|
discover_sensor($valid['sensor'], '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
|
||||||
create_sensor_to_state_index($device, $state_name, $index);
|
create_sensor_to_state_index($device, $state_name, $index);
|
||||||
$index++;
|
$index++;
|
||||||
@@ -105,4 +124,57 @@ if ($device['os'] == 'ibm-amm') {
|
|||||||
|
|
||||||
}//end foreach
|
}//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, array());
|
||||||
|
|
||||||
|
/* 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) {
|
||||||
|
|
||||||
|
$state_index_id = create_state_index($state_name);
|
||||||
|
|
||||||
|
if ($state_index_id) {
|
||||||
|
|
||||||
|
$states = array(
|
||||||
|
array($state_index_id, 'unknown', 0, 0, 3),
|
||||||
|
array($state_index_id, 'good', 1, 1, 0),
|
||||||
|
array($state_index_id, 'warning', 1, 2, 1),
|
||||||
|
array($state_index_id, 'notAvailable', 1, 3, -1),
|
||||||
|
array($state_index_id, 'critical', 1, 4, 2),
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($states as $value) {
|
||||||
|
$insert = array(
|
||||||
|
'state_index_id' => $value[0],
|
||||||
|
'state_descr' => $value[1],
|
||||||
|
'state_draw_graph' => $value[2],
|
||||||
|
'state_value' => $value[3],
|
||||||
|
'state_generic_value' => $value[4]
|
||||||
|
);
|
||||||
|
dbInsert($insert, 'state_translations');
|
||||||
|
}//end foreach
|
||||||
|
|
||||||
|
}//end if
|
||||||
|
|
||||||
|
discover_sensor($valid['sensor'], '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
|
||||||
|
|
||||||
}//end if
|
}//end if
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if ($device['os'] == 'ibm-amm') {
|
if ($device['os'] == 'ibm-amm') {
|
||||||
$oid = 'BLADE-MIB::mmTemp.0';
|
$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');
|
$mmtemp = snmp_get($device, $oid, '-Oqv');
|
||||||
|
|
||||||
preg_match('/[\d\.]+/', $mmtemp, $temp_response);
|
preg_match('/[\d\.]+/', $mmtemp, $temp_response);
|
||||||
@@ -28,7 +28,7 @@ if ($device['os'] == 'ibm-amm') {
|
|||||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $oid, 'ibm-amm', $descr, $divisor, '1', null, null, null, null, $current);
|
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $oid, 'ibm-amm', $descr, $divisor, '1', null, null, null, null, $current);
|
||||||
}
|
}
|
||||||
|
|
||||||
$oid = 'BLADE-MIB::frontPanelTemp.0';
|
$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');
|
$fptemp = snmp_get($device, $oid, '-Oqv');
|
||||||
|
|
||||||
preg_match('/[\d\.]+/', $fptemp, $temp_response);
|
preg_match('/[\d\.]+/', $fptemp, $temp_response);
|
||||||
|
|||||||
Reference in New Issue
Block a user