mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add Universal Input Output support for APC (#14766)
This commit is contained in:
@@ -2,22 +2,53 @@
|
||||
|
||||
// Environmental monitoring on UPSes etc
|
||||
// FIXME emConfigProbesTable may also be used? But not filled out on my device...
|
||||
$apc_env_data = snmpwalk_cache_oid($device, 'iemConfigProbesTable', [], 'PowerNet-MIB');
|
||||
$apc_env_data = snmpwalk_cache_oid($device, 'iemStatusProbesTable', $apc_env_data, 'PowerNet-MIB');
|
||||
$apc_env_data = snmpwalk_cache_oid($device, 'uioSensor', [], 'PowerNet-MIB', null, '-OQUse');
|
||||
if ($apc_env_data) {
|
||||
// NMC2/NMC3/etc Universal Input Output
|
||||
foreach (array_keys($apc_env_data) as $index) {
|
||||
$current = $apc_env_data[$index]['uioSensorStatusHumidity'];
|
||||
if ($current > 0) {
|
||||
// Humidity <= 0 -> Sensor not available
|
||||
$descr = $apc_env_data[$index]['uioSensorConfigSensorName'];
|
||||
$sensorType = 'apc';
|
||||
$oid = '.1.3.6.1.4.1.318.1.1.25.1.2.1.7.' . $index;
|
||||
|
||||
foreach (array_keys($apc_env_data) as $index) {
|
||||
$descr = $apc_env_data[$index]['iemStatusProbeName'];
|
||||
$current = $apc_env_data[$index]['iemStatusProbeCurrentHumid'];
|
||||
$sensorType = 'apc';
|
||||
$oid = '.1.3.6.1.4.1.318.1.1.10.2.3.2.1.6.' . $index;
|
||||
$low_limit = ($apc_env_data[$index]['iemConfigProbeMinHumidEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeMinHumidThreshold'] : null);
|
||||
$low_warn_limit = ($apc_env_data[$index]['iemConfigProbeLowHumidEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeLowHumidThreshold'] : null);
|
||||
$high_warn_limit = ($apc_env_data[$index]['iemConfigProbeHighHumidEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeHighHumidThreshold'] : null);
|
||||
$high_limit = ($apc_env_data[$index]['iemConfigProbeMaxHumidEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeMaxHumidThreshold'] : null);
|
||||
$low_limit = ($apc_env_data[$index]['uioSensorConfigMinHumidityEnable'] != 'disabled' ? $apc_env_data[$index]['uioSensorConfigMinHumidityThreshold'] : null);
|
||||
$low_warn_limit = ($apc_env_data[$index]['uioSensorConfigLowHumidityEnable'] != 'disabled' ? $apc_env_data[$index]['uioSensorConfigLowHumidityThreshold'] : null);
|
||||
$high_warn_limit = ($apc_env_data[$index]['uioSensorConfigHighHumidityEnable'] != 'disabled' ? $apc_env_data[$index]['uioSensorConfigHighHumidityThreshold'] : null);
|
||||
$high_limit = ($apc_env_data[$index]['uioSensorConfigMaxHumidityEnable'] != 'disabled' ? $apc_env_data[$index]['uioSensorConfigMaxHumidityThreshold'] : null);
|
||||
|
||||
if ($current > 0) {
|
||||
// Humidity = 0 -> Sensor not available
|
||||
discover_sensor($valid['sensor'], 'humidity', $device, $oid, $index, $sensorType, $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current);
|
||||
// universalInputOutput sensor entries all have an sub-index, presumably to allow for multiple sensors in the
|
||||
// future. Here we remove the sub-index from the first entry, so 1.1 becomes 1, 2.1 becomes 2, etc. However any
|
||||
// future appearing sub-index will remain untouched, so 1.2 will stay 1.2, 2.2 will stay 2.2, etc.
|
||||
// The reason that we remove the sub-index from the first entry is to preserve compatibility with sensors
|
||||
// created by prior versions using the legacy iemConfig and iemStatus tables.
|
||||
$split_index = explode('.', $index);
|
||||
if (count($split_index) == 2 && $split_index[1] == 1) {
|
||||
$index = $split_index[0];
|
||||
}
|
||||
discover_sensor($valid['sensor'], 'humidity', $device, $oid, $index, $sensorType, $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// NMC1 Integrated Environmental Monitor (legacy)
|
||||
$apc_env_data = snmpwalk_cache_oid($device, 'iemConfigProbesTable', [], 'PowerNet-MIB');
|
||||
$apc_env_data = snmpwalk_cache_oid($device, 'iemStatusProbesTable', $apc_env_data, 'PowerNet-MIB');
|
||||
|
||||
foreach (array_keys($apc_env_data) as $index) {
|
||||
$descr = $apc_env_data[$index]['iemStatusProbeName'];
|
||||
$current = $apc_env_data[$index]['iemStatusProbeCurrentHumid'];
|
||||
$sensorType = 'apc';
|
||||
$oid = '.1.3.6.1.4.1.318.1.1.10.2.3.2.1.6.' . $index;
|
||||
$low_limit = ($apc_env_data[$index]['iemConfigProbeMinHumidEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeMinHumidThreshold'] : null);
|
||||
$low_warn_limit = ($apc_env_data[$index]['iemConfigProbeLowHumidEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeLowHumidThreshold'] : null);
|
||||
$high_warn_limit = ($apc_env_data[$index]['iemConfigProbeHighHumidEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeHighHumidThreshold'] : null);
|
||||
$high_limit = ($apc_env_data[$index]['iemConfigProbeMaxHumidEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeMaxHumidThreshold'] : null);
|
||||
|
||||
if ($current > 0) {
|
||||
// Humidity = 0 -> Sensor not available
|
||||
discover_sensor($valid['sensor'], 'humidity', $device, $oid, $index, $sensorType, $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -158,35 +158,75 @@ foreach ($pre_cache['mem_sensors_status'] as $index => $data) {
|
||||
}
|
||||
|
||||
// Monitor contact switches via the UIO ports.
|
||||
$apcContactData = snmpwalk_cache_oid($device, 'iemConfigContactsTable', [], 'PowerNet-MIB', null, '-OQUse');
|
||||
$apcContactData = snmpwalk_cache_oid($device, 'iemStatusContactsTable', $apcContactData, 'PowerNet-MIB', null, '-OQUse');
|
||||
$apcContactData = snmpwalk_cache_oid($device, 'uioInputContact', $apcContactData, 'PowerNet-MIB', null, '-OQUse');
|
||||
if ($apcContactData) {
|
||||
// NMC2/NMC3/etc Universal Input Output
|
||||
foreach (array_keys($apcContactData) as $index) {
|
||||
// APC disabled (1), enabled (2)
|
||||
$current = $apcContactData[$index]['uioInputContactStatusCurrentState'];
|
||||
// state 4 is "not applicable"
|
||||
if ($current != 4) {
|
||||
$sensorType = 'apc';
|
||||
$cur_oid = '.1.3.6.1.4.1.318.1.1.25.2.2.1.5.' . $index;
|
||||
$severity = $apcContactData[$index]['uioInputContactStatusAlarmStatus'];
|
||||
|
||||
foreach (array_keys($apcContactData) as $index) {
|
||||
// APC disabled (1), enabled (2)
|
||||
if ($apcContactData[$index]['iemConfigContactEnable'] == 2) {
|
||||
$current = $apcContactData[$index]['iemStatusContactStatus'];
|
||||
$sensorType = 'apc';
|
||||
$cur_oid = '.1.3.6.1.4.1.318.1.1.10.2.3.4.1.3.' . $index;
|
||||
$severity = $apcContactData[$index]['iemConfigContactSeverity'];
|
||||
// APC normal (1), warning (2), critical (3), notaplicable (4)
|
||||
// LibreNMS warning (1), critical (2)
|
||||
|
||||
// APC critical (1), warning (2)
|
||||
// LibreNMS warning (1), critical (2)
|
||||
$faultGeneric = 1;
|
||||
if ($severity == 1) {
|
||||
$faultGeneric = 2;
|
||||
} elseif ($severity == 2) {
|
||||
$faultGeneric = 1;
|
||||
$state_name = $apcContactData[$index]['uioInputContactStatusContactName'];
|
||||
$states = [
|
||||
['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'normal'],
|
||||
['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'warning'],
|
||||
['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'critical'],
|
||||
];
|
||||
create_state_index($state_name, $states);
|
||||
|
||||
// universalInputOutput sensor entries all have an sub-index, presumably to allow for multiple sensors in the
|
||||
// future. Here we remove the sub-index from the first entry, so 1.1 becomes 1, 2.1 becomes 2, etc. However any
|
||||
// future appearing sub-index will remain untouched, so 1.2 will stay 1.2, 2.2 will stay 2.2, etc.
|
||||
// The reason that we remove the sub-index from the first entry is to preserve compatibility with sensors
|
||||
// created by prior versions using the legacy iemConfig and iemStatus tables.
|
||||
$split_index = explode('.', $index);
|
||||
if (count($split_index) == 2 && $split_index[1] == 1) {
|
||||
$index = $split_index[0];
|
||||
}
|
||||
|
||||
discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $state_name . '.' . $index, $state_name, $state_name, 1, 1, null, null, null, null, $current);
|
||||
create_sensor_to_state_index($device, $state_name, $state_name . '.' . $index);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// NMC1 Integrated Environmental Monitor (legacy)
|
||||
$apcContactData = snmpwalk_cache_oid($device, 'iemConfigContactsTable', [], 'PowerNet-MIB', null, '-OQUse');
|
||||
$apcContactData = snmpwalk_cache_oid($device, 'iemStatusContactsTable', $apcContactData, 'PowerNet-MIB', null, '-OQUse');
|
||||
|
||||
$state_name = $apcContactData[$index]['iemConfigContactName'];
|
||||
$states = [
|
||||
['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'noFault'],
|
||||
['value' => 2, 'generic' => $faultGeneric, 'graph' => 1, 'descr' => 'fault'],
|
||||
['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'disabled'],
|
||||
];
|
||||
create_state_index($state_name, $states);
|
||||
foreach (array_keys($apcContactData) as $index) {
|
||||
// APC disabled (1), enabled (2)
|
||||
if ($apcContactData[$index]['iemConfigContactEnable'] == 2) {
|
||||
$current = $apcContactData[$index]['iemStatusContactStatus'];
|
||||
$sensorType = 'apc';
|
||||
$cur_oid = '.1.3.6.1.4.1.318.1.1.10.2.3.4.1.3.' . $index;
|
||||
$severity = $apcContactData[$index]['iemConfigContactSeverity'];
|
||||
|
||||
discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $state_name . '.' . $index, $state_name, $state_name, 1, 1, null, null, null, null, $current);
|
||||
create_sensor_to_state_index($device, $state_name, $state_name . '.' . $index);
|
||||
// APC critical (1), warning (2)
|
||||
// LibreNMS warning (1), critical (2)
|
||||
$faultGeneric = 1;
|
||||
if ($severity == 1) {
|
||||
$faultGeneric = 2;
|
||||
} elseif ($severity == 2) {
|
||||
$faultGeneric = 1;
|
||||
}
|
||||
|
||||
$state_name = $apcContactData[$index]['iemConfigContactName'];
|
||||
$states = [
|
||||
['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'noFault'],
|
||||
['value' => 2, 'generic' => $faultGeneric, 'graph' => 1, 'descr' => 'fault'],
|
||||
['value' => 3, 'generic' => 0, 'graph' => 0, 'descr' => 'disabled'],
|
||||
];
|
||||
create_state_index($state_name, $states);
|
||||
|
||||
discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $state_name . '.' . $index, $state_name, $state_name, 1, 1, null, null, null, null, $current);
|
||||
create_sensor_to_state_index($device, $state_name, $state_name . '.' . $index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,27 +23,59 @@ if ($oids) {
|
||||
}
|
||||
|
||||
// Environmental monitoring on UPSes etc
|
||||
$apc_env_data = snmpwalk_cache_oid($device, 'iemConfigProbesTable', [], 'PowerNet-MIB', null, '-OQUse');
|
||||
$apc_env_data = snmpwalk_cache_oid($device, 'iemStatusProbesTable', $apc_env_data, 'PowerNet-MIB', null, '-OQUse');
|
||||
|
||||
foreach (array_keys($apc_env_data) as $index) {
|
||||
// APC connected(2), disconnected(1)
|
||||
if ($apc_env_data[$index]['iemStatusProbeStatus'] != 1) {
|
||||
$descr = $apc_env_data[$index]['iemStatusProbeName'];
|
||||
$current = $apc_env_data[$index]['iemStatusProbeCurrentTemp'];
|
||||
$sensorType = 'apc';
|
||||
$oid = '.1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.' . $index;
|
||||
// APC enum disabled(1), enabled(2)
|
||||
$low_limit = ($apc_env_data[$index]['iemConfigProbeMinTempEnable'] != 1 ? $apc_env_data[$index]['iemConfigProbeMinTempThreshold'] : null);
|
||||
$low_warn_limit = ($apc_env_data[$index]['iemConfigProbeLowTempEnable'] != 1 ? $apc_env_data[$index]['iemConfigProbeLowTempThreshold'] : null);
|
||||
$high_warn_limit = ($apc_env_data[$index]['iemConfigProbeHighTempEnable'] != 1 ? $apc_env_data[$index]['iemConfigProbeHighTempThreshold'] : null);
|
||||
$high_limit = ($apc_env_data[$index]['iemConfigProbeMaxTempEnable'] != 1 ? $apc_env_data[$index]['iemConfigProbeMaxTempThreshold'] : null);
|
||||
|
||||
$apc_env_data = snmpwalk_cache_oid($device, 'uioSensor', [], 'PowerNet-MIB', null, '-OQUse');
|
||||
if ($apc_env_data) {
|
||||
// NMC2/NMC3/etc. Universal Input Output
|
||||
foreach (array_keys($apc_env_data) as $index) {
|
||||
$current = $apc_env_data[$index]['uioSensorStatusTemperatureDegC'];
|
||||
if ($current > 0) {
|
||||
// Temperature = 0 -> Sensor not available
|
||||
// Temperature <= 0 -> Sensor not available
|
||||
$descr = $apc_env_data[$index]['uioSensorConfigSensorName'];
|
||||
$sensorType = 'apc';
|
||||
$oid = '.1.3.6.1.4.1.318.1.1.25.1.2.1.6.' . $index;
|
||||
|
||||
// APC enum disabled(1), enabled(2)
|
||||
$low_limit = ($apc_env_data[$index]['uioSensorConfigMinTemperatureEnable'] != 1 ? $apc_env_data[$index]['uioSensorConfigMinTemperatureThreshold'] : null);
|
||||
$low_warn_limit = ($apc_env_data[$index]['uioSensorConfigLowTemperatureEnable'] != 1 ? $apc_env_data[$index]['uioSensorConfigLowTemperatureThreshold'] : null);
|
||||
$high_warn_limit = ($apc_env_data[$index]['uioSensorConfigHighTemperatureEnable'] != 1 ? $apc_env_data[$index]['uioSensorConfigHighTemperatureThreshold'] : null);
|
||||
$high_limit = ($apc_env_data[$index]['uioSensorConfigMaxTemperatureEnable'] != 1 ? $apc_env_data[$index]['uioSensorConfigMaxTemperatureThreshold'] : null);
|
||||
|
||||
// universalInputOutput sensor entries all have an sub-index, presumably to allow for multiple sensors in the
|
||||
// future. Here we remove the sub-index from the first entry, so 1.1 becomes 1, 2.1 becomes 2, etc. However any
|
||||
// future appearing sub-index will remain untouched, so 1.2 will stay 1.2, 2.2 will stay 2.2, etc.
|
||||
// The reason that we remove the sub-index from the first entry is to preserve compatibility with sensors
|
||||
// created by prior versions using the legacy iemConfig and iemStatus tables.
|
||||
$split_index = explode('.', $index);
|
||||
if (count($split_index) == 2 && $split_index[1] == 1) {
|
||||
$index = $split_index[0];
|
||||
}
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $sensorType, $descr, 1, 1, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// NMC1 Integrated Environmental Monitor (legacy)
|
||||
$apc_env_data = snmpwalk_cache_oid($device, 'iemConfigProbesTable', [], 'PowerNet-MIB', null, '-OQUse');
|
||||
$apc_env_data = snmpwalk_cache_oid($device, 'iemStatusProbesTable', $apc_env_data, 'PowerNet-MIB', null, '-OQUse');
|
||||
|
||||
foreach (array_keys($apc_env_data) as $index) {
|
||||
// APC connected(2), disconnected(1)
|
||||
if ($apc_env_data[$index]['iemStatusProbeStatus'] != 1) {
|
||||
$descr = $apc_env_data[$index]['iemStatusProbeName'];
|
||||
$current = $apc_env_data[$index]['iemStatusProbeCurrentTemp'];
|
||||
$sensorType = 'apc';
|
||||
$oid = '.1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.' . $index;
|
||||
// APC enum disabled(1), enabled(2)
|
||||
$low_limit = ($apc_env_data[$index]['iemConfigProbeMinTempEnable'] != 1 ? $apc_env_data[$index]['iemConfigProbeMinTempThreshold'] : null);
|
||||
$low_warn_limit = ($apc_env_data[$index]['iemConfigProbeLowTempEnable'] != 1 ? $apc_env_data[$index]['iemConfigProbeLowTempThreshold'] : null);
|
||||
$high_warn_limit = ($apc_env_data[$index]['iemConfigProbeHighTempEnable'] != 1 ? $apc_env_data[$index]['iemConfigProbeHighTempThreshold'] : null);
|
||||
$high_limit = ($apc_env_data[$index]['iemConfigProbeMaxTempEnable'] != 1 ? $apc_env_data[$index]['iemConfigProbeMaxTempThreshold'] : null);
|
||||
|
||||
if ($current > 0) {
|
||||
// Temperature = 0 -> Sensor not available
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $sensorType, $descr, 1, 1, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$apc_env_data = snmpwalk_cache_oid($device, 'emsProbeStatus', [], 'PowerNet-MIB');
|
||||
|
Reference in New Issue
Block a user