OPNsense poller better reporting of Version and Platform (#11350)

* OPNsense better reporting of Version and Platform

OPNsense can now report exact version and platform, if the settings in OPNsense is ticked "Display Verion in OID".

* OPNsense poller change to better type check

OPNsense poller change to better type check on $OIDVersionString, which returns false if not found but contains string if it is.

* Add missing bracket to if statement

Add missing bracket to if statement on $OIDVersionString

* OPNsense poll add required spaces to function call

OPNsense poller add required spaces to function call, for coding style checks to pass.

* OPNsense test data json files

OPNsense test data json files
This commit is contained in:
FingerlessGloves
2020-04-01 19:12:55 +01:00
committed by GitHub
parent 60533e0bf9
commit f34f552c57
3 changed files with 88 additions and 0 deletions

View File

@@ -26,3 +26,11 @@
$output = preg_split("/ /", $device['sysDescr']);
$version = $output[2];
$hardware = $output[6];
// 20.1 onwards you can enable Display Version OID, which gives use the exact release number
$OIDVersionString = snmp_get($device, ".1.3.6.1.4.1.8072.1.3.2.3.1.2.7.118.101.114.115.105.111.110", '-Oqv');
if (is_string($OIDVersionString)) {
$OIDVersionArray = preg_split("/ /", $OIDVersionString);
$version = $OIDVersionArray[1];
$hardware = preg_replace('/\(|\)/', '', $OIDVersionArray[2]);
}

40
tests/data/opnsense.json Normal file
View File

@@ -0,0 +1,40 @@
{
"os": {
"discovery": {
"devices": [
{
"sysName": "",
"sysObjectID": ".1.3.6.1.4.1.12325.1.1.2.1.1",
"sysDescr": "OPNsense OPNsense.7p.lan 18.1.1-a5575d7bd OPNsense FreeBSD 11.1-RELEASE-p6 amd64",
"sysContact": null,
"version": null,
"hardware": null,
"features": null,
"os": "opnsense",
"type": "firewall",
"serial": null,
"icon": "opnsense.png",
"location": null
}
]
},
"poller": {
"devices": [
{
"sysName": "",
"sysObjectID": ".1.3.6.1.4.1.12325.1.1.2.1.1",
"sysDescr": "OPNsense OPNsense.7p.lan 18.1.1-a5575d7bd OPNsense FreeBSD 11.1-RELEASE-p6 amd64",
"sysContact": null,
"version": "18.1.1-a5575d7bd",
"hardware": "amd64",
"features": null,
"os": "opnsense",
"type": "firewall",
"serial": null,
"icon": "opnsense.png",
"location": null
}
]
}
}
}

View File

@@ -0,0 +1,40 @@
{
"os": {
"discovery": {
"devices": [
{
"sysName": "",
"sysObjectID": ".1.3.6.1.4.1.8072.3.2.8",
"sysDescr": "FreeBSD fw1-eri1.OPN 11.2-RELEASE-p16-HBSD FreeBSD 11.2-RELEASE-p16-HBSD fc65add89c3(stable/20.1) amd64",
"sysContact": null,
"version": null,
"hardware": null,
"features": null,
"os": "opnsense",
"type": "firewall",
"serial": null,
"icon": "opnsense.png",
"location": null
}
]
},
"poller": {
"devices": [
{
"sysName": "",
"sysObjectID": ".1.3.6.1.4.1.8072.3.2.8",
"sysDescr": "FreeBSD fw1-eri1.OPN 11.2-RELEASE-p16-HBSD FreeBSD 11.2-RELEASE-p16-HBSD fc65add89c3(stable/20.1) amd64",
"sysContact": null,
"version": "20.1.2",
"hardware": "amd64/OpenSSL",
"features": null,
"os": "opnsense",
"type": "firewall",
"serial": null,
"icon": "opnsense.png",
"location": null
}
]
}
}
}