Skip to content

Commit 7ae2557

Browse files
murrantStyleCIBot
andauthored
Merge enlogic-pdu os (librenms#18245)
* Merge enlogic-pdu os they are the same and having separate allows devices to become undetected * rename test files * Fix up test data * Fix yaml spacing * Use PHP and detect which MIB to use. * Apply fixes from StyleCI * rename pre-cache --------- Co-authored-by: StyleCI Bot <[email protected]>
1 parent a3ac1f7 commit 7ae2557

File tree

13 files changed

+223
-468
lines changed

13 files changed

+223
-468
lines changed

LibreNMS/OS/EnlogicPdu.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
/**
4+
* EnlogicPdu.php
5+
*
6+
* -Description-
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
* @link https://www.librenms.org
22+
*
23+
* @copyright 2025 Tony Murray
24+
* @author Tony Murray <[email protected]>
25+
*/
26+
27+
namespace LibreNMS\OS;
28+
29+
use App\Models\Device;
30+
use LibreNMS\OS;
31+
use SnmpQuery;
32+
33+
class EnlogicPdu extends OS
34+
{
35+
public function discoverOS(Device $device): void
36+
{
37+
// try new mib first, they moved oids in this MIB, so we have to check the contents of the version to make sure
38+
$pdu2 = SnmpQuery::get([
39+
'ENLOGIC-PDU2-MIB::pduNamePlatePartNumber.1',
40+
'ENLOGIC-PDU2-MIB::pduNamePlateSerialNumber.1',
41+
'ENLOGIC-PDU2-MIB::pduNamePlateFirmwareVersion.1',
42+
]);
43+
44+
if (preg_match('/\d\.\d\.\d/', $pdu2->value('ENLOGIC-PDU2-MIB::pduNamePlateFirmwareVersion.1'))) {
45+
$device->version = $pdu2->value('ENLOGIC-PDU2-MIB::pduNamePlateFirmwareVersion.1');
46+
$device->serial = $pdu2->value('ENLOGIC-PDU2-MIB::pduNamePlateSerialNumber.1');
47+
$device->hardware = $pdu2->value('ENLOGIC-PDU2-MIB::pduNamePlatePartNumber.1');
48+
49+
return;
50+
}
51+
52+
$pdu1 = SnmpQuery::get([
53+
'ENLOGIC-PDU-MIB::pduNamePlateModelNumber.1',
54+
'ENLOGIC-PDU-MIB::pduNamePlateSerialNumber.1',
55+
'ENLOGIC-PDU-MIB::pduNamePlateFirmwareVersion.1',
56+
]);
57+
58+
$device->version = $pdu1->value('ENLOGIC-PDU-MIB::pduNamePlateFirmwareVersion.1');
59+
$device->serial = $pdu1->value('ENLOGIC-PDU-MIB::pduNamePlateSerialNumber.1');
60+
$device->hardware = $pdu1->value('ENLOGIC-PDU-MIB::pduNamePlateModelNumber.1');
61+
}
62+
}

includes/discovery/sensors/current/enlogic-pdu.inc.php

Lines changed: 0 additions & 60 deletions
This file was deleted.

includes/discovery/sensors/power/enlogic-pdu.inc.php

Lines changed: 0 additions & 47 deletions
This file was deleted.

includes/discovery/sensors/pre-cache/enlogic-pdu.inc.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

includes/discovery/sensors/state/enlogic-pdu.inc.php

Lines changed: 0 additions & 117 deletions
This file was deleted.

includes/discovery/sensors/voltage/enlogic-pdu.inc.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

resources/definitions/os_detection/enlogic-pdu.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ over:
66
- { graph: device_voltage, text: Voltage }
77
- { graph: device_current, text: Current }
88
- { graph: device_power, text: Power }
9+
- { graph: device_state, text: State }
910
mib_dir: enlogic
1011
discovery:
11-
- sysObjectID: .1.3.6.1.4.1.38446.
12-
snmpget_except:
13-
oid: ENLOGIC-PDU2-MIB::pduNamePlateType.1
14-
op: ">="
15-
value: '1'
12+
-
13+
sysObjectID: .1.3.6.1.4.1.38446.

0 commit comments

Comments
 (0)