VRP: improving extraction of HW and Version (#9167)

* VRP: improving extraction of HW and Version

* VRP: Improving extraction of HW and Version - CodeClimate update

* VRP: Improving extraction of HW and Version - Review and debug code cleaning

* VRP: Improving extraction of HW and Version - resolve OIDs and swap order of poll

* VRP: Improving extraction of HW and Version - resolve OIDs and swap order of poll

* Device: VRP: Update test data

* Device: VRP: Travis code clean

* Device: VRP: Update test data for variants

* Device: VRP: Update test data for variants
This commit is contained in:
PipoCanaja
2018-09-14 15:05:03 +02:00
committed by Tony Murray
parent cc225bd39c
commit 1041c640bb
6 changed files with 13547 additions and 13415 deletions

View File

@@ -1,6 +1,32 @@
<?php
$hardware = trim(snmp_get($device, '.1.3.6.1.4.1.2011.2.33.20.1.1.1.3.0', '-OQv'), '"');
//Huawei VRP devices are not providing the HW description in a unified way
preg_match("/Version .*\n/", $device['sysDescr'], $matches);
preg_match("/Version [^\s]*/m", $device['sysDescr'], $matches);
$version = trim(str_replace('Version ', '', $matches[0]));
preg_match("/\(([^\s]*) (V[0-9]{3}R[0-9]{3}[0-9A-Z]+)/m", $device['sysDescr'], $matches);
if (!empty($matches[2])) {
$version .= " (" . trim($matches[2]) . ")";
}
$oidList = [
'HUAWEI-ENTITY-EXTENT-MIB::hwEntityExtentMIB.6.5.0',
'HUAWEI-DEVICE-EXT-MIB::hwProductName.0',
'HUAWEI-MIB::hwDatacomm.183.1.25.1.5.1',
'HUAWEI-MIB::mlsr.20.1.1.1.3.0',
];
foreach ($oidList as $oid) {
$hardware_tmp = snmp_get($device, $oid, '-OQv');
if (!empty($hardware_tmp)) {
$hardware = "Huawei " . $hardware_tmp;
break;
}
}
// Let's use sysDescr if nothing else is found in the OIDs. sysDescr is less detailled than OIDs most of the time
if (empty($hardware_tmp) && !empty($matches[1])) {
$hardware = "Huawei " . trim($matches[1]);
}

View File

@@ -4,5 +4,43 @@
"processors": []
},
"poller": "matches discovery"
},
"os": {
"discovery": {
"devices": [
{
"sysName": "",
"sysObjectID": ".1.3.6.1.4.1.2011.2.224.1",
"sysDescr": "Huawei AR1220 Huawei Versatile Routing Platform Software VRP (R) software,Version 5.120 (AR1220 V200R003C01SPC900) Copyright (C) 2011-2013 Huawei Technologies Co., Ltd",
"sysContact": null,
"version": null,
"hardware": null,
"features": null,
"location": null,
"os": "vrp",
"type": "network",
"serial": null,
"icon": "huawei.svg"
}
]
},
"poller": {
"devices": [
{
"sysName": "",
"sysObjectID": ".1.3.6.1.4.1.2011.2.224.1",
"sysDescr": "Huawei AR1220 Huawei Versatile Routing Platform Software VRP (R) software,Version 5.120 (AR1220 V200R003C01SPC900) Copyright (C) 2011-2013 Huawei Technologies Co., Ltd",
"sysContact": null,
"version": "5.120 (V200R003C01SPC900)",
"hardware": "Huawei AR1220",
"features": null,
"location": null,
"os": "vrp",
"type": "network",
"serial": null,
"icon": "huawei.svg"
}
]
}
}
}

View File

@@ -25,8 +25,8 @@
"sysObjectID": ".1.3.6.1.4.1.2011.2.23.291",
"sysDescr": "S5720-56C-PWR-EI-AC\nHuawei Versatile Routing Platform Software \r\n VRP (R) software,Version 5.170 (S5720 V200R010C00SPC600) \r\n Copyright (C) 2007 Huawei Technologies Co., Ltd.",
"sysContact": "<private>",
"version": "5.170 (S5720 V200R010C00SPC600)",
"hardware": null,
"version": "5.170 (V200R010C00SPC600)",
"hardware": "Huawei S5720",
"features": null,
"location": "<private>",
"os": "vrp",
@@ -34385,7 +34385,7 @@
"sensor_descr": "XGigabitEthernet0/0/1",
"sensor_divisor": 1000000,
"sensor_multiplier": 1,
"sensor_current": 0.0051,
"sensor_current": 0.0051000000000000004,
"sensor_limit": 0.0076500000000000005,
"sensor_limit_warn": null,
"sensor_limit_low": null,
@@ -34408,8 +34408,8 @@
"sensor_descr": "XGigabitEthernet1/0/1",
"sensor_divisor": 1000000,
"sensor_multiplier": 1,
"sensor_current": 0.005498,
"sensor_limit": 0.008247,
"sensor_current": 0.0054980000000000003,
"sensor_limit": 0.0082470000000000009,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
@@ -34431,8 +34431,8 @@
"sensor_descr": "XGigabitEthernet2/0/1",
"sensor_divisor": 1000000,
"sensor_multiplier": 1,
"sensor_current": 0.006082,
"sensor_limit": 0.009123,
"sensor_current": 0.0060819999999999997,
"sensor_limit": 0.0091229999999999992,
"sensor_limit_warn": null,
"sensor_limit_low": null,
"sensor_limit_low_warn": null,
@@ -34477,10 +34477,10 @@
"sensor_descr": "XGigabitEthernet1/0/1 Rx",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_current": -2.58060922270801,
"sensor_current": -2.5806092227080102,
"sensor_limit": -2.4515787615726095,
"sensor_limit_warn": null,
"sensor_limit_low": -2.709639683843411,
"sensor_limit_low": -2.7096396838434109,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
@@ -34500,7 +34500,7 @@
"sensor_descr": "XGigabitEthernet2/0/1 Rx",
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_current": -3.036436112666679,
"sensor_current": -3.0364361126666788,
"sensor_limit": -2.8846143070333445,
"sensor_limit_warn": null,
"sensor_limit_low": -3.188257918300013,
@@ -34547,7 +34547,7 @@
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_current": -2.2112552799726046,
"sensor_limit": -2.100692515973974,
"sensor_limit": -2.1006925159739742,
"sensor_limit_warn": null,
"sensor_limit_low": -2.321818043971235,
"sensor_limit_low_warn": null,
@@ -34570,7 +34570,7 @@
"sensor_divisor": 1,
"sensor_multiplier": 1,
"sensor_current": -2.3433144524098592,
"sensor_limit": -2.226148729789366,
"sensor_limit": -2.2261487297893661,
"sensor_limit_warn": null,
"sensor_limit_low": -2.4604801750303524,
"sensor_limit_low_warn": null,
@@ -34730,10 +34730,10 @@
"sensor_descr": "XGigabitEthernet0/0/1",
"sensor_divisor": 1000,
"sensor_multiplier": 1,
"sensor_current": 3.309,
"sensor_limit": 3.80535,
"sensor_current": 3.3090000000000002,
"sensor_limit": 3.8053499999999998,
"sensor_limit_warn": null,
"sensor_limit_low": 2.81265,
"sensor_limit_low": 2.8126500000000001,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
@@ -34753,10 +34753,10 @@
"sensor_descr": "XGigabitEthernet1/0/1",
"sensor_divisor": 1000,
"sensor_multiplier": 1,
"sensor_current": 3.265,
"sensor_current": 3.2650000000000001,
"sensor_limit": 3.75475,
"sensor_limit_warn": null,
"sensor_limit_low": 2.77525,
"sensor_limit_low": 2.7752500000000002,
"sensor_limit_low_warn": null,
"sensor_alert": 1,
"sensor_custom": "No",
@@ -34776,7 +34776,7 @@
"sensor_descr": "XGigabitEthernet2/0/1",
"sensor_divisor": 1000,
"sensor_multiplier": 1,
"sensor_current": 3.288,
"sensor_current": 3.2879999999999998,
"sensor_limit": 3.7811999999999997,
"sensor_limit_warn": null,
"sensor_limit_low": 2.7948,

File diff suppressed because it is too large Load Diff

View File

@@ -25,8 +25,8 @@
"sysObjectID": ".1.3.6.1.4.1.2011.2.239.1",
"sysDescr": "Huawei Versatile Routing Platform Software\nVRP (R) software, Version 8.150 (CE12800 V200R002C50SPC800) \r\nCopyright (C) 2012-2017 Huawei Technologies Co., Ltd. \r\nHUAWEICE12804",
"sysContact": "<private>",
"version": "8.150 (CE12800 V200R002C50SPC800)",
"hardware": "",
"version": "8.150 (V200R002C50SPC800)",
"hardware": "Huawei CE12800",
"features": null,
"location": "<private>",
"os": "vrp",

File diff suppressed because it is too large Load Diff