mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
newdevice: APC Environmental monitoring units #5140
This commit is contained in:
@@ -1569,6 +1569,33 @@ function load_all_os($restricted = array())
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $scale
|
||||
* @param $value
|
||||
* @return float
|
||||
*/
|
||||
function fahrenheit_to_celsius($scale, $value)
|
||||
{
|
||||
if ($scale === 'fahrenheit') {
|
||||
$value = ($value - 32) / 1.8;
|
||||
}
|
||||
return sprintf('%.02f', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param null $default
|
||||
* @param int $min
|
||||
* @return null
|
||||
*/
|
||||
function set_null($value, $default = null, $min = 0)
|
||||
{
|
||||
if (!isset($value) || !is_numeric($value) || (isset($min) && $value <= $min)) {
|
||||
$value = $default;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param $value
|
||||
* @param int $default
|
||||
* @return int
|
||||
|
||||
9
includes/definitions/aos-emu2.yaml
Normal file
9
includes/definitions/aos-emu2.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
os: aos-emu2
|
||||
text: 'APC Environmental Monitoring Unit'
|
||||
type: environment
|
||||
icon: apc
|
||||
mib_dir:
|
||||
- apc
|
||||
discovery:
|
||||
- sysObjectId:
|
||||
- .1.3.6.1.4.1.318.1.3.8.3
|
||||
@@ -179,6 +179,11 @@ function discover_device($device, $options = null)
|
||||
function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, $divisor = '1', $multiplier = '1', $low_limit = null, $low_warn_limit = null, $warn_limit = null, $high_limit = null, $current = null, $poller_type = 'snmp', $entPhysicalIndex = null, $entPhysicalIndex_measured = null)
|
||||
{
|
||||
|
||||
$low_limit = set_null($low_limit);
|
||||
$low_warn_limit = set_null($low_warn_limit);
|
||||
$warn_limit = set_null($warn_limit);
|
||||
$high_limit = set_null($high_limit);
|
||||
|
||||
if (!is_numeric($divisor)) {
|
||||
$divisor = 1;
|
||||
}
|
||||
|
||||
40
includes/discovery/sensors/humidity/aos-emu2.inc.php
Normal file
40
includes/discovery/sensors/humidity/aos-emu2.inc.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* aos-emu2.inc.php
|
||||
*
|
||||
* LibreNMS sensors humidity discovery module for APC EMU2
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2016 Neil Lathwood
|
||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||
*/
|
||||
|
||||
if ($device['os'] === 'aos-emu2') {
|
||||
foreach ($emu2_temp as $id => $temp) {
|
||||
if (isset($temp['emsProbeStatusProbeHumidity']) && $temp['emsProbeStatusProbeHumidity'] > 0) {
|
||||
$index = $temp['emsProbeStatusProbeIndex'];
|
||||
$oid = '.1.3.6.1.4.1.318.1.1.10.3.13.1.1.6.' . $index;
|
||||
$descr = $temp['emsProbeStatusProbeName'];
|
||||
$low_limit = $temp['emsProbeStatusProbeMinHumidityThresh'];
|
||||
$low_warn_limit = $temp['emsProbeStatusProbeLowHumidityThresh'];
|
||||
$high_limit = $temp['emsProbeStatusProbeMaxHumidityThresh'];
|
||||
$high_warn_limit = $temp['emsProbeStatusProbeHighHumidityThresh'];
|
||||
$current = $temp['emsProbeStatusProbeHumidity'];
|
||||
discover_sensor($valid['sensor'], 'humidity', $device, $oid, $index, 'aos-emu2', $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
includes/discovery/sensors/pre-cache/aos-emu2.inc.php
Normal file
27
includes/discovery/sensors/pre-cache/aos-emu2.inc.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* aos-emu2.inc.php
|
||||
*
|
||||
* LibreNMS sensors pre-cache discovery module for APC EMU2
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2016 Neil Lathwood
|
||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||
*/
|
||||
|
||||
$emu2_temp_scale = snmp_get($device, 'emsStatusSysTempUnits.0', '-OQv', 'PowerNet-MIB');
|
||||
$emu2_temp = snmpwalk_cache_oid($device, 'emsProbeStatusEntry', array(), 'PowerNet-MIB');
|
||||
40
includes/discovery/sensors/temperatures/aos-emu2.inc.php
Normal file
40
includes/discovery/sensors/temperatures/aos-emu2.inc.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* aos-emu2.inc.php
|
||||
*
|
||||
* LibreNMS sensors temp discovery module for APC EMU2
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2016 Neil Lathwood
|
||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||
*/
|
||||
|
||||
if ($device['os'] === 'aos-emu2') {
|
||||
foreach ($emu2_temp as $id => $temp) {
|
||||
if (isset($temp['emsProbeStatusProbeTemperature']) && $temp['emsProbeStatusProbeTemperature'] > 0) {
|
||||
$index = $temp['emsProbeStatusProbeIndex'];
|
||||
$oid = '.1.3.6.1.4.1.318.1.1.10.3.13.1.1.3.' . $index;
|
||||
$descr = $temp['emsProbeStatusProbeName'];
|
||||
$low_limit = fahrenheit_to_celsius($emu2_temp_scale, $temp['emsProbeStatusProbeMinTempThresh']);
|
||||
$low_warn_limit = fahrenheit_to_celsius($emu2_temp_scale, $temp['emsProbeStatusProbeLowTempThresh']);
|
||||
$high_limit = fahrenheit_to_celsius($emu2_temp_scale, $temp['emsProbeStatusProbeMaxTempThresh']);
|
||||
$high_warn_limit = fahrenheit_to_celsius($emu2_temp_scale, $temp['emsProbeStatusProbeHighTempThresh']);
|
||||
$current = fahrenheit_to_celsius($emu2_temp_scale, $temp['emsProbeStatusProbeTemperature']);
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'aos-emu2', $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,19 @@ function bulk_sensor_snmpget($device, $sensors)
|
||||
return $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $device
|
||||
* @return array
|
||||
*/
|
||||
function sensor_precache($device)
|
||||
{
|
||||
$sensor_config = array();
|
||||
if (file_exists('includes/polling/sensors/pre-cache/'. $device['os'] .'.inc.php')) {
|
||||
include 'includes/polling/sensors/pre-cache/'. $device['os'] .'.inc.php';
|
||||
}
|
||||
return $sensor_config;
|
||||
}
|
||||
|
||||
function poll_sensor($device, $class, $unit)
|
||||
{
|
||||
global $config, $memcache, $agent_sensors;
|
||||
@@ -23,6 +36,7 @@ function poll_sensor($device, $class, $unit)
|
||||
$sensors = array();
|
||||
$misc_sensors = array();
|
||||
$all_sensors = array();
|
||||
|
||||
foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ?', array($class, $device['device_id'])) as $sensor) {
|
||||
if ($sensor['poller_type'] == 'agent') {
|
||||
$misc_sensors[] = $sensor;
|
||||
@@ -35,6 +49,8 @@ function poll_sensor($device, $class, $unit)
|
||||
|
||||
$snmp_data = bulk_sensor_snmpget($device, $sensors);
|
||||
|
||||
$sensor_cache = sensor_precache($device);
|
||||
|
||||
foreach ($sensors as $sensor) {
|
||||
echo 'Checking (' . $sensor['poller_type'] . ") $class " . $sensor['sensor_descr'] . '... '.PHP_EOL;
|
||||
|
||||
@@ -44,7 +60,7 @@ function poll_sensor($device, $class, $unit)
|
||||
$sensor_value = trim(str_replace('"', '', $snmp_data[$sensor['sensor_oid']]));
|
||||
|
||||
if (file_exists('includes/polling/sensors/'. $class .'/'. $device['os'] .'.inc.php')) {
|
||||
require_once 'includes/polling/sensors/'. $class .'/'. $device['os'] .'.inc.php';
|
||||
require 'includes/polling/sensors/'. $class .'/'. $device['os'] .'.inc.php';
|
||||
}
|
||||
|
||||
|
||||
|
||||
32
includes/polling/os/aos-emu2.inc.php
Normal file
32
includes/polling/os/aos-emu2.inc.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* aos-emu2.inc.php
|
||||
*
|
||||
* LibreNMS os discovery module for APC EMU2
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2016 Neil Lathwood
|
||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||
*/
|
||||
|
||||
$aos_emu2_data = snmp_get_multi_oid($device, 'emsIdentSerialNumber.0 emsIdentProductNumber.0 emsIdentHardwareRev.0 emsIdentFirmwareRev.0', '-OQUs', 'PowerNet-MIB');
|
||||
|
||||
$serial = trim($aos_emu2_data['emsIdentSerialNumber.0'], '"');
|
||||
$hardware = trim($aos_emu2_data['emsIdentProductNumber.0'], '"') . ' ' . trim($aos_emu2_data['emsIdentHardwareRev.0'], '"');
|
||||
$version = trim($aos_emu2_data['emsIdentFirmwareRev.0'], '"');
|
||||
|
||||
unset($aos_emu2_data);
|
||||
26
includes/polling/sensors/pre-cache/aos-emu2.inc.php
Normal file
26
includes/polling/sensors/pre-cache/aos-emu2.inc.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* aos-emu2.inc.php
|
||||
*
|
||||
* LibreNMS sensors pre-cache poller module for APC EMU2
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2016 Neil Lathwood
|
||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||
*/
|
||||
|
||||
$sensor_config['scale'] = snmp_get($device, 'emsStatusSysTempUnits.0', '-OQv', 'PowerNet-MIB');
|
||||
26
includes/polling/sensors/temperature/aos-emu2.inc.php
Normal file
26
includes/polling/sensors/temperature/aos-emu2.inc.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* aos-emu2.inc.php
|
||||
*
|
||||
* LibreNMS sensors temp poller module for APC EMU2
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2016 Neil Lathwood
|
||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||
*/
|
||||
|
||||
$sensor_value = fahrenheit_to_celsius($sensor_cache['scale'], $sensor_value);
|
||||
Reference in New Issue
Block a user