From 5697d2486966045fbe0eb74995c712ea660231a2 Mon Sep 17 00:00:00 2001 From: PipoCanaja <38363551+PipoCanaja@users.noreply.github.com> Date: Tue, 9 Apr 2019 21:03:07 +0200 Subject: [PATCH] Added Cisco Small business bootloader + HW version (#10043) DO NOT DELETE THIS TEXT #### Please note > Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. - [X] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) #### Testers If you would like to test this pull request then please run: `./scripts/github-apply `, i.e `./scripts/github-apply 5926` After you are done testing, you can remove the changes with `./scripts/github-remove`. If there are schema changes, you can ask on discord how to revert. --- includes/polling/os/ciscosb.inc.php | 30 +++++++++++++++++--- tests/data/ciscosb.json | 2 +- tests/data/ciscosb_esw540_8p.json | 19 ++++++++++++- tests/data/ciscosb_sg350-10.json | 38 ++++++++++++++++++++++++++ tests/data/ciscosb_sg550x-24.json | 19 ++++++++++++- tests/snmpsim/ciscosb.snmprec | 1 + tests/snmpsim/ciscosb_sg350-10.snmprec | 2 ++ 7 files changed, 104 insertions(+), 7 deletions(-) diff --git a/includes/polling/os/ciscosb.inc.php b/includes/polling/os/ciscosb.inc.php index 0e6af687ff..d21101fbaa 100644 --- a/includes/polling/os/ciscosb.inc.php +++ b/includes/polling/os/ciscosb.inc.php @@ -3,6 +3,7 @@ * LibreNMS Cisco Small Business OS information module * * Copyright (c) 2015 Mike Rostermund + * Copyright (c) 2019 PipoCanaja (github.com/pipocanaja) * 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 @@ -10,12 +11,33 @@ * the source code distribution for details. */ +$data = snmp_get_multi($device, ['genGroupHWVersion.0', 'rlPhdUnitGenParamModelName.1', 'rlPhdUnitGenParamHardwareVersion.1', 'rlPhdUnitGenParamSerialNum.1', 'rlPhdUnitGenParamSoftwareVersion.1', 'rlPhdUnitGenParamFirmwareVersion.1'], '-OQUs', 'CISCOSB-DEVICEPARAMS-MIB:CISCOSB-Physicaldescription-MIB'); + +$hardware = $data['1']['rlPhdUnitGenParamHardwareVersion'] . " " . $data['1']['rlPhdUnitGenParamSoftwareVersion']; + +$serial = $data['1']['rlPhdUnitGenParamSerialNum']; + +$hwversion = $data['0']['genGroupHWVersion']; +if (! $hwversion) { + $hwversion = $data['1']['rlPhdUnitGenParamHardwareVersion']; +} if ($device['sysObjectID'] == '.1.3.6.1.4.1.9.6.1.89.26.1') { $hardware = 'SG220-26'; } else { - $hardware = str_replace(' ', '', snmp_get($device, 'rlPhdUnitGenParamModelName.1', '-Ovq', 'CISCOSB-Physicaldescription-MIB')); + $hardware = str_replace(' ', '', $data['1']['rlPhdUnitGenParamModelName']); +} +if ($hwversion) { + $hardware .= " " . $hwversion; } -$version = snmp_get($device, 'rlPhdUnitGenParamSoftwareVersion.1', '-Ovq', 'CISCOSB-Physicaldescription-MIB'); -$serial = snmp_get($device, 'rlPhdUnitGenParamSerialNum.1', '-Ovq', 'CISCOSB-Physicaldescription-MIB'); -$features = snmp_get($device, 'rlPhdUnitGenParamServiceTag.1', '-Ovq', 'CISCOSB-Physicaldescription-MIB'); +$version = 'Software ' . $data['1']['rlPhdUnitGenParamSoftwareVersion']; +$boot = $data['0']['rndBaseBootVersion']; +$firmware = $data['1']['rlPhdUnitGenParamFirmwareVersion']; +if ($boot) { + $version = "$version, Bootldr $boot"; +} +if ($firmware) { + $version = "$version, Firmware $firmware"; +} + +$features = $data['1']['rlPhdUnitGenParamServiceTag']; diff --git a/tests/data/ciscosb.json b/tests/data/ciscosb.json index 7fda869729..b42e30117e 100644 --- a/tests/data/ciscosb.json +++ b/tests/data/ciscosb.json @@ -43,7 +43,7 @@ "sysObjectID": ".1.3.6.1.4.1.9.6.1.80", "sysDescr": "Linux, Cisco Systems, Inc WAP371 (WAP371-A-K9), Version 1.3.0.4", "sysContact": "", - "version": null, + "version": "Software 1.3.0.4", "hardware": null, "features": null, "os": "ciscosb", diff --git a/tests/data/ciscosb_esw540_8p.json b/tests/data/ciscosb_esw540_8p.json index 45e8ed8f46..7ef904418a 100644 --- a/tests/data/ciscosb_esw540_8p.json +++ b/tests/data/ciscosb_esw540_8p.json @@ -18,6 +18,23 @@ } ] }, - "poller": "matches discovery" + "poller": { + "devices": [ + { + "sysName": "", + "sysObjectID": ".1.3.6.1.4.1.9.1.1176", + "sysDescr": "8-port 10/100/1000 Ethernet Switch with PoE", + "sysContact": null, + "version": "Software ", + "hardware": null, + "features": null, + "os": "ciscosb", + "type": "network", + "serial": null, + "icon": "cisco.svg", + "location": null + } + ] + } } } diff --git a/tests/data/ciscosb_sg350-10.json b/tests/data/ciscosb_sg350-10.json index 1aa6d84f41..d4a94fc4a2 100644 --- a/tests/data/ciscosb_sg350-10.json +++ b/tests/data/ciscosb_sg350-10.json @@ -4838,5 +4838,43 @@ } ] } + }, + "os": { + "discovery": { + "devices": [ + { + "sysName": "", + "sysObjectID": ".1.3.6.1.4.1.9.6.1.95.10.3", + "sysDescr": "SG350-10 10-Port Gigabit Managed Switch", + "sysContact": null, + "version": null, + "hardware": null, + "features": null, + "os": "ciscosb", + "type": "network", + "serial": null, + "icon": "cisco.svg", + "location": null + } + ] + }, + "poller": { + "devices": [ + { + "sysName": "", + "sysObjectID": ".1.3.6.1.4.1.9.6.1.95.10.3", + "sysDescr": "SG350-10 10-Port Gigabit Managed Switch", + "sysContact": "", + "version": "Software 1.0.0, Firmware 1.0.0", + "hardware": null, + "features": null, + "os": "ciscosb", + "type": "network", + "serial": null, + "icon": "cisco.svg", + "location": "" + } + ] + } } } diff --git a/tests/data/ciscosb_sg550x-24.json b/tests/data/ciscosb_sg550x-24.json index 3c2d98ff23..acb3b9c49f 100644 --- a/tests/data/ciscosb_sg550x-24.json +++ b/tests/data/ciscosb_sg550x-24.json @@ -18,6 +18,23 @@ } ] }, - "poller": "matches discovery" + "poller": { + "devices": [ + { + "sysName": "", + "sysObjectID": ".1.3.6.1.4.1.9.6.1.93.24.1", + "sysDescr": "SG550X-24 24-Port Gigabit Stackable Managed Switch", + "sysContact": null, + "version": "Software ", + "hardware": null, + "features": null, + "os": "ciscosb", + "type": "network", + "serial": null, + "icon": "cisco.svg", + "location": null + } + ] + } } } diff --git a/tests/snmpsim/ciscosb.snmprec b/tests/snmpsim/ciscosb.snmprec index 06cabcb3b7..188a6e4892 100644 --- a/tests/snmpsim/ciscosb.snmprec +++ b/tests/snmpsim/ciscosb.snmprec @@ -449,3 +449,4 @@ 1.3.6.1.2.1.47.1.1.1.1.15.1|4| 1.3.6.1.2.1.47.1.1.1.1.16.1|2|1 1.3.6.1.4.1.9.6.1.101.1.8.0|2|42 +1.3.6.1.4.1.9.6.1.101.53.14.1.2.1|4|1.3.0.4 diff --git a/tests/snmpsim/ciscosb_sg350-10.snmprec b/tests/snmpsim/ciscosb_sg350-10.snmprec index 1ff2015ab5..106b153d1f 100644 --- a/tests/snmpsim/ciscosb_sg350-10.snmprec +++ b/tests/snmpsim/ciscosb_sg350-10.snmprec @@ -519,4 +519,6 @@ 1.3.6.1.2.1.31.1.1.1.18.9000|4| 1.3.6.1.2.1.31.1.1.1.18.20000|4| 1.3.6.1.2.1.31.1.1.1.18.100000|4| +1.3.6.1.4.1.9.6.1.101.53.14.1.2.1|4|1.0.0 +1.3.6.1.4.1.9.6.1.101.53.14.1.3.1|4|1.0.0 1.3.6.1.6.3.10.2.1.3.0|2|115880