2016-12-05 00:13:55 +02:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* LibreNMS
|
|
|
|
*
|
2017-11-15 21:10:08 +01:00
|
|
|
* Copyright (c) 2016 Søren Friis Rosiak <sorenrosiak@gmail.com>
|
2016-12-05 00:13:55 +02:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2017-02-03 12:39:38 +00:00
|
|
|
$temp = snmp_get($device, "upsAdvBatteryReplaceIndicator.0", "-Ovqe", "PowerNet-MIB");
|
|
|
|
$cur_oid = '.1.3.6.1.4.1.318.1.1.1.2.2.4.0';
|
|
|
|
$index = '0';
|
2016-12-05 00:13:55 +02:00
|
|
|
|
2017-02-03 12:39:38 +00:00
|
|
|
if (is_numeric($temp)) {
|
|
|
|
//Create State Index
|
|
|
|
$state_name = 'upsAdvBatteryReplaceIndicator';
|
2019-03-04 17:31:17 +00:00
|
|
|
$states = [
|
|
|
|
['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'noBatteryNeedsReplacing'],
|
|
|
|
['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'batteryNeedsReplacing'],
|
|
|
|
];
|
|
|
|
create_state_index($state_name, $states);
|
2016-12-05 00:13:55 +02:00
|
|
|
|
2017-02-03 12:39:38 +00:00
|
|
|
$descr = 'UPS Battery Replacement Status';
|
|
|
|
//Discover Sensors
|
2019-03-04 17:31:17 +00:00
|
|
|
discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp, 'snmp', $index);
|
2016-12-05 00:13:55 +02:00
|
|
|
|
2017-02-03 12:39:38 +00:00
|
|
|
//Create Sensor To State Index
|
|
|
|
create_sensor_to_state_index($device, $state_name, $index);
|
|
|
|
}
|
2017-01-07 00:09:41 +00:00
|
|
|
|
2019-03-04 17:31:17 +00:00
|
|
|
$cooling_status = snmpwalk_cache_oid($device, 'coolingUnitStatusDiscreteEntry', [], 'PowerNet-MIB');
|
2017-02-03 12:39:38 +00:00
|
|
|
foreach ($cooling_status as $index => $data) {
|
|
|
|
$cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.4.2.2.1.4.' . $index;
|
|
|
|
$state_name = $data['coolingUnitStatusDiscreteDescription'];
|
2019-03-04 17:31:17 +00:00
|
|
|
|
|
|
|
$tmp_states = explode(',', $data['coolingUnitStatusDiscreteIntegerReferenceKey']);
|
|
|
|
$states = [];
|
|
|
|
foreach ($tmp_states as $k => $ref) {
|
|
|
|
preg_match('/([\w]+)\\(([\d]+)\\)/', $ref, $matches);
|
|
|
|
$nagios_state = get_nagios_state($matches[1]);
|
|
|
|
$states[] = ['value' => 0, 'generic' => $nagios_state, 'graph' => 0, $matches[2], 'descr' => $matches[1]];
|
2017-01-07 00:09:41 +00:00
|
|
|
}
|
2019-03-04 17:31:17 +00:00
|
|
|
create_state_index($state_name, $states);
|
|
|
|
|
|
|
|
discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, 'apc', $state_name, 1, 1, null, null, null, null, $data['coolingUnitStatusDiscreteValueAsInteger']);
|
2017-02-03 12:39:38 +00:00
|
|
|
create_sensor_to_state_index($device, $state_name, $index);
|
|
|
|
}
|
2017-01-07 00:09:41 +00:00
|
|
|
|
2017-02-03 12:39:38 +00:00
|
|
|
unset($cooling_status);
|
2017-01-07 00:09:41 +00:00
|
|
|
|
2019-03-04 17:31:17 +00:00
|
|
|
$cooling_unit = snmpwalk_cache_oid($device, 'coolingUnitExtendedDiscreteEntry', [], 'PowerNet-MIB');
|
2017-02-03 12:39:38 +00:00
|
|
|
foreach ($cooling_unit as $index => $data) {
|
|
|
|
$cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.6.2.2.1.4.' . $index;
|
|
|
|
$state_name = $data['coolingUnitExtendedDiscreteDescription'];
|
2019-03-04 17:31:17 +00:00
|
|
|
|
|
|
|
$tmp_states = explode(',', $data['coolingUnitExtendedDiscreteIntegerReferenceKey']);
|
|
|
|
$states = [];
|
|
|
|
foreach ($tmp_states as $k => $ref) {
|
|
|
|
preg_match('/([\w]+)\\(([\d]+)\\)/', $ref, $matches);
|
|
|
|
$nagios_state = get_nagios_state($matches[1]);
|
|
|
|
$states[] = ['value' => 0, 'generic' => $nagios_state, 'graph' => 0, $matches[2], 'descr' => $matches[1]];
|
2017-01-07 00:09:41 +00:00
|
|
|
}
|
2019-03-04 17:31:17 +00:00
|
|
|
create_state_index($state_name, $states);
|
|
|
|
|
|
|
|
discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, 'apc', $state_name, 1, 1, null, null, null, null, $data['coolingUnitExtendedDiscreteValueAsInteger']);
|
2017-02-03 12:39:38 +00:00
|
|
|
create_sensor_to_state_index($device, $state_name, $index);
|
2016-12-05 00:13:55 +02:00
|
|
|
}
|
2017-02-03 12:39:38 +00:00
|
|
|
|
|
|
|
unset($cooling_unit);
|
2017-02-09 07:59:36 +00:00
|
|
|
|
2019-03-04 17:31:17 +00:00
|
|
|
$relays = snmpwalk_cache_oid($device, 'emsOutputRelayControlEntry', [], 'PowerNet-MIB');
|
2017-02-09 07:59:36 +00:00
|
|
|
foreach ($relays as $index => $data) {
|
|
|
|
$cur_oid = '.1.3.6.1.4.1.318.1.1.10.3.2.1.1.3.' . $index;
|
|
|
|
$state_name = $data['emsOutputRelayControlOutputRelayName'];
|
2019-03-04 17:31:17 +00:00
|
|
|
$states = [
|
|
|
|
['value' => 1, 'generic' => 2, 'graph' => 0, 'descr' => 'immediateCloseEMS'],
|
|
|
|
['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'immediateOpenEMS'],
|
|
|
|
];
|
|
|
|
create_state_index($state_name, $states);
|
|
|
|
|
2017-02-09 07:59:36 +00:00
|
|
|
$current = apc_relay_state($data['emsOutputRelayControlOutputRelayCommand']);
|
|
|
|
if (is_numeric($current)) {
|
2019-03-04 17:31:17 +00:00
|
|
|
discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, $state_name, $state_name, 1, 1, null, null, null, null, $current);
|
2017-05-17 22:41:53 +01:00
|
|
|
create_sensor_to_state_index($device, $state_name, $cur_oid);
|
2017-02-09 07:59:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
unset(
|
|
|
|
$relays,
|
|
|
|
$index,
|
|
|
|
$data
|
|
|
|
);
|
|
|
|
|
2019-03-04 17:31:17 +00:00
|
|
|
$switched = snmpwalk_cache_oid($device, 'emsOutletControlEntry', [], 'PowerNet-MIB');
|
2017-02-09 07:59:36 +00:00
|
|
|
foreach ($switched as $index => $data) {
|
|
|
|
$cur_oid = '.1.3.6.1.4.1.318.1.1.10.3.3.1.1.3.' . $index;
|
|
|
|
$state_name = $data['emsOutletControlOutletName'];
|
2019-03-04 17:31:17 +00:00
|
|
|
$states = [
|
|
|
|
['value' => 1, 'generic' => 2, 'graph' => 0, 'descr' => 'immediateOnEMS'],
|
|
|
|
['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'immediateOffEMS'],
|
|
|
|
];
|
|
|
|
create_state_index($state_name, $states);
|
|
|
|
|
2017-02-09 07:59:36 +00:00
|
|
|
$current = apc_relay_state($data['emsOutletControlOutletCommand']);
|
|
|
|
if (is_numeric($current)) {
|
2019-03-04 17:31:17 +00:00
|
|
|
discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $cur_oid, $state_name, $state_name, 1, 1, null, null, null, null, $current);
|
2017-05-17 22:41:53 +01:00
|
|
|
create_sensor_to_state_index($device, $state_name, $cur_oid);
|
2017-02-09 07:59:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
unset(
|
|
|
|
$switched,
|
|
|
|
$index,
|
|
|
|
$data
|
|
|
|
);
|
2017-05-17 22:41:53 +01:00
|
|
|
|
|
|
|
foreach ($pre_cache['mem_sensors_status'] as $index => $data) {
|
|
|
|
if ($data['memSensorsCommStatus']) {
|
|
|
|
$cur_oid = '.1.3.6.1.4.1.318.1.1.10.4.2.3.1.7.' . $index;
|
|
|
|
$state_name = 'memSensorsCommStatus';
|
2019-03-04 17:31:17 +00:00
|
|
|
$states = [
|
|
|
|
['value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'notInstalled'],
|
|
|
|
['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'commsOK'],
|
|
|
|
['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'commsLost'],
|
|
|
|
];
|
|
|
|
create_state_index($state_name, $states);
|
|
|
|
|
2017-05-17 22:41:53 +01:00
|
|
|
$current = $data['memSensorsCommStatus'];
|
|
|
|
}
|
|
|
|
$descr = $data['memSensorsStatusSensorName'] . ' - ' . $data['memSensorsStatusSensorLocation'];
|
|
|
|
$divisor = 1;
|
|
|
|
$multiplier = 1;
|
|
|
|
if (is_numeric($current)) {
|
2019-03-04 17:31:17 +00:00
|
|
|
discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $state_name . '.' . $index, $state_name, $state_name, 1, 1, null, null, null, null, $current);
|
2017-05-17 22:41:53 +01:00
|
|
|
create_sensor_to_state_index($device, $state_name, $state_name . '.' . $index);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($data['memSensorsAlarmStatus']) {
|
|
|
|
$cur_oid = '.1.3.6.1.4.1.318.1.1.10.4.2.3.1.8.' . $index;
|
|
|
|
$state_name = 'memSensorsAlarmStatus';
|
2019-03-04 17:31:17 +00:00
|
|
|
$states = [
|
|
|
|
['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'memNormal'],
|
|
|
|
['value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'memWarning'],
|
|
|
|
['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'memCritical'],
|
|
|
|
];
|
|
|
|
create_state_index($state_name, $states);
|
|
|
|
|
2017-05-17 22:41:53 +01:00
|
|
|
$current = $data['memSensorsAlarmStatus'];
|
|
|
|
}
|
|
|
|
$descr = $data['memSensorsStatusSensorName'] . ' - ' . $data['memSensorsStatusSensorLocation'];
|
|
|
|
$divisor = 1;
|
|
|
|
$multiplier = 1;
|
|
|
|
if (is_numeric($current)) {
|
2019-03-04 17:31:17 +00:00
|
|
|
discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $state_name . '.' . $index, $state_name, $state_name, 1, 1, null, null, null, null, $current);
|
2017-05-17 22:41:53 +01:00
|
|
|
create_sensor_to_state_index($device, $state_name, $state_name . '.' . $index);
|
|
|
|
}
|
|
|
|
}
|