newdevice: Added additional sensor support for Huawei VRP #4279

This commit is contained in:
Neil Lathwood 2017-01-19 16:42:57 +00:00 committed by GitHub
parent 6df39b9bbd
commit 01e4ac3d58
9 changed files with 351 additions and 0 deletions

View File

@ -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

View File

@ -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

View 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
);
}
}
}

View 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
);
}
}
}

View 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');
}

View 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
);
}
}
}

View 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
);
}
}
}

View 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);

View File

@ -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)
{