Skip to content

Commit a90aec7

Browse files
authored
Remove FortiAP hardware table (and use FAPversion with regex) (librenms#18460)
* WIP: Remove fortiap hardware table * FortiAP use fapVersion (and regex) for hardware there is the name of hardware on version and also update test
1 parent 7304255 commit a90aec7

File tree

4 files changed

+6
-54
lines changed

4 files changed

+6
-54
lines changed

LibreNMS/OS/Fortiap.php

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,71 +14,19 @@
1414

1515
namespace LibreNMS\OS;
1616

17-
use App\Models\Device;
1817
use LibreNMS\Device\WirelessSensor;
19-
use LibreNMS\Interfaces\Discovery\OSDiscovery;
2018
use LibreNMS\Interfaces\Discovery\Sensors\WirelessClientsDiscovery;
2119
use LibreNMS\Interfaces\Discovery\Sensors\WirelessFrequencyDiscovery;
2220
use LibreNMS\Interfaces\Discovery\Sensors\WirelessPowerDiscovery;
2321
use LibreNMS\Interfaces\Polling\Sensors\WirelessFrequencyPolling;
2422
use LibreNMS\OS\Shared\Fortinet;
2523

2624
class Fortiap extends Fortinet implements
27-
OSDiscovery,
2825
WirelessClientsDiscovery,
2926
WirelessFrequencyDiscovery,
3027
WirelessFrequencyPolling,
3128
WirelessPowerDiscovery
3229
{
33-
protected function getHardwareName()
34-
{
35-
$rewrite_fortiap_hardware = [
36-
'.1.3.6.1.4.1.12356.120.10.23112' => 'FAP-231F',
37-
'.1.3.6.1.4.1.12356.120.10.23412' => 'FAP-234F',
38-
'.1.3.6.1.4.1.12356.120.10.23912' => 'FAP-23JF',
39-
'.1.3.6.1.4.1.12356.120.10.43112' => 'FAP-431F',
40-
'.1.3.6.1.4.1.12356.120.10.43212' => 'FAP-432F',
41-
'.1.3.6.1.4.1.12356.120.10.43312' => 'FAP-433F',
42-
'.1.3.6.1.4.1.12356.120.10.83112' => 'FAP-831F',
43-
'.1.3.6.1.4.1.12356.120.10.22111' => 'FAP-221E',
44-
'.1.3.6.1.4.1.12356.120.10.22211' => 'FAP-222E',
45-
'.1.3.6.1.4.1.12356.120.10.22311' => 'FAP-223E',
46-
'.1.3.6.1.4.1.12356.120.10.22411' => 'FAP-224E',
47-
'.1.3.6.1.4.1.12356.120.10.23111' => 'FAP-231E',
48-
'.1.3.6.1.4.1.12356.120.10.32111' => 'FAP-321E',
49-
'.1.3.6.1.4.1.12356.120.10.42111' => 'FAP-421E',
50-
'.1.3.6.1.4.1.12356.120.10.42311' => 'FAP-423E',
51-
'.1.3.6.1.4.1.12356.120.10.22131' => 'FAP-S221E',
52-
'.1.3.6.1.4.1.12356.120.10.22331' => 'FAP-S223E',
53-
'.1.3.6.1.4.1.12356.120.10.42131' => 'FAP-S421E',
54-
'.1.3.6.1.4.1.12356.120.10.42231' => 'FAP-S422E',
55-
'.1.3.6.1.4.1.12356.120.10.42331' => 'FAP-S423E',
56-
'.1.3.6.1.4.1.12356.120.10.24941' => 'FAP-C24JE',
57-
'.1.3.6.1.4.1.12356.120.10.22121' => 'FAP-U221EV',
58-
'.1.3.6.1.4.1.12356.120.10.22321' => 'FAP-U223EV',
59-
'.1.3.6.1.4.1.12356.120.10.24921' => 'FAP-U24JEV',
60-
'.1.3.6.1.4.1.12356.120.10.32121' => 'FAP-U321EV',
61-
'.1.3.6.1.4.1.12356.120.10.32321' => 'FAP-U323EV',
62-
'.1.3.6.1.4.1.12356.120.10.42121' => 'FAP-U421EV',
63-
'.1.3.6.1.4.1.12356.120.10.42221' => 'FAP-U422EV',
64-
'.1.3.6.1.4.1.12356.120.10.42321' => 'FAP-U423EV',
65-
'.1.3.6.1.4.1.12356.120.10.23122' => 'FAP-U231F',
66-
'.1.3.6.1.4.1.12356.120.10.23422' => 'FAP-U234F',
67-
'.1.3.6.1.4.1.12356.120.10.43122' => 'FAP-U431F',
68-
'.1.3.6.1.4.1.12356.120.10.43222' => 'FAP-U432F',
69-
'.1.3.6.1.4.1.12356.120.10.43322' => 'FAP-U433F',
70-
];
71-
72-
return $rewrite_fortiap_hardware[$this->getDevice()->sysObjectID] ?? null;
73-
}
74-
75-
public function discoverOS(Device $device): void
76-
{
77-
parent::discoverOS($device); // yaml
78-
79-
$device->hardware = $device->hardware ?: $this->getHardwareName();
80-
}
81-
8230
public function discoverWirelessClients()
8331
{
8432
$fapVapStaInfoCounts = snmpwalk_cache_oid($this->getDeviceArray(), 'fapVapStaInfoCount', [], 'FORTINET-FORTIAP-MIB');

resources/definitions/os_discovery/fortiap.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ modules:
33
os:
44
version: FORTINET-FORTIAP-MIB::fapVersion.0
55
serial: FORTINET-FORTIAP-MIB::fapSerialNum.0
6+
hardware: FORTINET-FORTIAP-MIB::fapVersion.0
7+
hardware_regex: '/(?<hardware>FP\d+[A-Z])/i'
8+
hardware_replace:
9+
- ['/FP/', 'FortiAP ']
610
mempools:
711
data:
812
-

tests/data/fortiap_fap231g.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"sysDescr": "DE-HIDDEN-DMN-OFF-OP-AP02",
99
"sysContact": "<private>",
1010
"version": "FP231G-v7.4-build0771",
11-
"hardware": null,
11+
"hardware": "FortiAP 231G",
1212
"features": null,
1313
"location": "<private>",
1414
"os": "fortiap",

tests/data/fortiap_fap831f.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"sysDescr": "<private>",
99
"sysContact": "<private>",
1010
"version": "FP831F-v7.0-build0127",
11-
"hardware": "FAP-831F",
11+
"hardware": "FortiAP 831F",
1212
"features": null,
1313
"location": null,
1414
"os": "fortiap",

0 commit comments

Comments
 (0)