Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for APC AP9810 zone contacts #9967

Merged
merged 5 commits into from Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion includes/discovery/sensors/load/apc.inc.php
Expand Up @@ -24,7 +24,7 @@
'AdvOid' => 'upsAdvOutputLoad',
'type' => 'apc',
'index' => 0,
'descr' => 'Load',
'descr' => 'Load(VA)',
'divisor' => 10,
'mib' => '+PowerNet-MIB',
],
Expand Down
34 changes: 34 additions & 0 deletions includes/discovery/sensors/state/apc.inc.php
Expand Up @@ -156,3 +156,37 @@
create_sensor_to_state_index($device, $state_name, $state_name . '.' . $index);
}
}

// 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');

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 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);
}
}
29 changes: 16 additions & 13 deletions includes/discovery/sensors/temperature/apc.inc.php
Expand Up @@ -15,21 +15,24 @@
}

// 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, '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) {
$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;
$low_limit = ($apc_env_data[$index]['iemConfigProbeMinTempEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeMinTempThreshold'] : null);
$low_warn_limit = ($apc_env_data[$index]['iemConfigProbeLowTempEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeLowTempThreshold'] : null);
$high_warn_limit = ($apc_env_data[$index]['iemConfigProbeHighTempEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeHighTempThreshold'] : null);
$high_limit = ($apc_env_data[$index]['iemConfigProbeMaxTempEnable'] != 'disabled' ? $apc_env_data[$index]['iemConfigProbeMaxTempThreshold'] : null);

discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $sensorType, $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current);
// 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);

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');
Expand Down