mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 18:38:25 +00:00
newdevice: Added additional sensor support for Huawei VRP #4279
This commit is contained in:
parent
6df39b9bbd
commit
01e4ac3d58
@ -1581,6 +1581,11 @@ function fahrenheit_to_celsius($scale, $value)
|
||||
return sprintf('%.02f', $value);
|
||||
}
|
||||
|
||||
function uw_to_dbm($value)
|
||||
{
|
||||
return 10 * log10($value / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param null $default
|
||||
|
@ -3,6 +3,12 @@ group: vrp
|
||||
text: 'Huawei VRP'
|
||||
type: network
|
||||
icon: huawei
|
||||
over:
|
||||
- { graph: device_bits, text: 'Device Traffic' }
|
||||
- { graph: device_processor, text: 'Processor Usage' }
|
||||
- { graph: device_mempool, text: 'Memory Usage' }
|
||||
mib_dir:
|
||||
- huawei
|
||||
discovery:
|
||||
- sysDescr:
|
||||
- VRP (R) Software
|
||||
|
52
includes/discovery/sensors/current/vrp.inc.php
Normal file
52
includes/discovery/sensors/current/vrp.inc.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* vrp.inc.php
|
||||
*
|
||||
* LibreNMS current sensor discovery module for VRP
|
||||
*
|
||||
* 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'] === 'vrp') {
|
||||
echo 'Huawei VRP ';
|
||||
$data = $vrp_oids['hwEntityOpticalBiasCurrent'];
|
||||
|
||||
foreach ($data as $index => $value) {
|
||||
if (is_numeric($value) && $value >= 0) {
|
||||
$oid = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.7.' . $index;
|
||||
$descr = $vrp_oids['entPhysicalName'][$index];
|
||||
discover_sensor(
|
||||
$valid['sensor'],
|
||||
'current',
|
||||
$device,
|
||||
$oid,
|
||||
$index,
|
||||
'vrp',
|
||||
$descr,
|
||||
1000,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
70,
|
||||
75,
|
||||
$value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
79
includes/discovery/sensors/dbm/vrp.inc.php
Normal file
79
includes/discovery/sensors/dbm/vrp.inc.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* vrp.inc.php
|
||||
*
|
||||
* LibreNMS dbm sensor discovery module for VRP
|
||||
*
|
||||
* 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'] === 'vrp') {
|
||||
echo 'Huawei VRP ';
|
||||
$data = $vrp_oids['hwEntityOpticalRxPower'];
|
||||
|
||||
foreach ($data as $index => $value) {
|
||||
if (is_numeric($value) && $value >= 0) {
|
||||
$value = uw_to_dbm($value);
|
||||
$oid = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.8.' . $index;
|
||||
$descr = $vrp_oids['entPhysicalName'][$index] . ' Rx';
|
||||
discover_sensor(
|
||||
$valid['sensor'],
|
||||
'dbm',
|
||||
$device,
|
||||
$oid,
|
||||
'rx-' . $index,
|
||||
'vrp',
|
||||
$descr,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
70,
|
||||
75,
|
||||
$value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$data = $vrp_oids['hwEntityOpticalTxPower'];
|
||||
|
||||
foreach ($data as $index => $value) {
|
||||
if (is_numeric($value) && $value >= 0) {
|
||||
$value = uw_to_dbm($value);
|
||||
$oid = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.9.' . $index;
|
||||
$descr = $vrp_oids['entPhysicalName'][$index] . ' Tx';
|
||||
discover_sensor(
|
||||
$valid['sensor'],
|
||||
'dbm',
|
||||
$device,
|
||||
$oid,
|
||||
'tx-' . $index,
|
||||
'vrp',
|
||||
$descr,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
70,
|
||||
75,
|
||||
$value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
35
includes/discovery/sensors/pre-cache/vrp.inc.php
Normal file
35
includes/discovery/sensors/pre-cache/vrp.inc.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* vrp.inc.php
|
||||
*
|
||||
* LibreNMS sensor pre-cache discovery module for VRP
|
||||
*
|
||||
* 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'] == 'vrp') {
|
||||
echo 'Pre-cache VRP: ';
|
||||
|
||||
$vrp_oids = array();
|
||||
echo 'Caching OIDs:';
|
||||
|
||||
$vrp_oids = snmpwalk_cache_index($device, '.1.3.6.1.4.1.2011.5.25.31.1.1.1.1', array(), 'HUAWEI-ENTITY-EXTENT-MIB');
|
||||
$vrp_oids = snmpwalk_cache_index($device, '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1', $vrp_oids, 'HUAWEI-ENTITY-EXTENT-MIB');
|
||||
$vrp_oids = snmpwalk_cache_index($device, '.1.3.6.1.2.1.47.1.1.1.1.7', $vrp_oids, 'HUAWEI-ENTITY-EXTENT-MIB');
|
||||
}
|
80
includes/discovery/sensors/temperatures/vrp.inc.php
Normal file
80
includes/discovery/sensors/temperatures/vrp.inc.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* vrp.inc.php
|
||||
*
|
||||
* LibreNMS temperature sensor discovery module for VRP
|
||||
*
|
||||
* 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'] === 'vrp') {
|
||||
echo 'Huawei VRP ';
|
||||
|
||||
$data = $vrp_oids['hwEntityTemperature'];
|
||||
|
||||
foreach ($data as $index => $value) {
|
||||
if (is_numeric($value) && $value > 0) {
|
||||
$oid = '.1.3.6.1.4.1.2011.5.25.31.1.1.1.1.11.' . $index;
|
||||
$descr = $vrp_oids['entPhysicalName'][$index];
|
||||
$high_temp_thresh = $vrp_oids['hwEntityTemperatureThreshold'][$index];
|
||||
$low_temp_thresh = $vrp_oids['hwEntityTemperatureLowThreshold'][$index];
|
||||
discover_sensor(
|
||||
$valid['sensor'],
|
||||
'temperature',
|
||||
$device,
|
||||
$oid,
|
||||
$index,
|
||||
'vrp',
|
||||
$descr,
|
||||
1,
|
||||
1,
|
||||
$low_temp_thresh,
|
||||
$low_temp_thresh,
|
||||
$high_temp_thresh,
|
||||
$high_temp_thresh,
|
||||
$value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$data = $vrp_oids['hwEntityOpticalTemperature'];
|
||||
|
||||
foreach ($data as $index => $value) {
|
||||
if (is_numeric($value) && $value >= 0) {
|
||||
$oid = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.5.' . $index;
|
||||
$descr = $vrp_oids['entPhysicalName'][$index];
|
||||
discover_sensor(
|
||||
$valid['sensor'],
|
||||
'temperature',
|
||||
$device,
|
||||
$oid,
|
||||
$index,
|
||||
'vrp',
|
||||
$descr,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
70,
|
||||
75,
|
||||
$value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
52
includes/discovery/sensors/voltages/vrp.inc.php
Normal file
52
includes/discovery/sensors/voltages/vrp.inc.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* vrp.inc.php
|
||||
*
|
||||
* LibreNMS voltage sensor discovery module for VRP
|
||||
*
|
||||
* 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'] === 'vrp') {
|
||||
echo 'Huawei VRP ';
|
||||
$data = $vrp_oids['hwEntityOpticalVoltage'];
|
||||
|
||||
foreach ($data as $index => $value) {
|
||||
if (is_numeric($value) && $value >= 0) {
|
||||
$oid = '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.6.' . $index;
|
||||
$descr = $vrp_oids['entPhysicalName'][$index];
|
||||
discover_sensor(
|
||||
$valid['sensor'],
|
||||
'voltage',
|
||||
$device,
|
||||
$oid,
|
||||
$index,
|
||||
'vrp',
|
||||
$descr,
|
||||
1000,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
70,
|
||||
75,
|
||||
$value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
26
includes/polling/sensors/dbm/vrp.inc.php
Normal file
26
includes/polling/sensors/dbm/vrp.inc.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* vrp.inc.php
|
||||
*
|
||||
* LibreNMS dbm sensor poller module for VRP
|
||||
*
|
||||
* 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 = uw_to_dbm($sensor_value);
|
@ -443,6 +443,22 @@ function snmpwalk_cache_double_oid($device, $oid, $array, $mib = null, $mibdir =
|
||||
return $array;
|
||||
}//end snmpwalk_cache_double_oid()
|
||||
|
||||
function snmpwalk_cache_index($device, $oid, $array, $mib = null, $mibdir = null)
|
||||
{
|
||||
$data = snmp_walk($device, $oid, '-OQUs', $mib, $mibdir);
|
||||
|
||||
foreach (explode("\n", $data) as $entry) {
|
||||
list($oid,$value) = explode('=', $entry, 2);
|
||||
$oid = trim($oid);
|
||||
$value = trim($value);
|
||||
list($oid, $first) = explode('.', $oid);
|
||||
if (!strstr($value, 'at this OID') && isset($oid) && isset($first)) {
|
||||
$array[$oid][$first] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}//end snmpwalk_cache_double_oid()
|
||||
|
||||
function snmpwalk_cache_triple_oid($device, $oid, $array, $mib = null, $mibdir = null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user