Tozz
8 January 2024 10:42
1
I recently made a PR to add PSU sensor state support for Aruba switches. The PR can be found here:
librenms:master
← rudybroersma:arubaos-cx
opened 03:27PM - 03 Jan 24 UTC
This is a pull request to add:
1. PSU (Power Supply) state sensor support
2. A… dd additional OIDs for serial number and software/firmware version
Addition 1:
Currently, LibreNMS does not have a state sensor to monitor the power supply status (ok/fail).
When I pull the power cord on one of the PSUs the operStatus changes to nonoperational.
Addition 2:
The current discovery yaml expects the serial number to be at:
ENTITY-MIB::entPhysicalSerialNum.1
All Aruba's I have (6200s and 6300s) have the serial number at
ENTITY-MIB::entPhysicalSoftwareRev.101001
I believe the difference has to do with the fact that atleast the 6000-series seem to believe the device itself is just a container and the switch is a virtual (?) blade, identified as 101001. In reality though it's just a simple 1U fixed config device.
snmpsim test data added. ./lnms dev:check succeeds. Added a little screenshot of the new state sensor as an example:
![aruba-state-sensor](https://github.com/librenms/librenms/assets/2853200/b9d92fdc-2e40-4b07-b305-42fbc2a988b1)
DO NOT DELETE THE UNDERLYING TEXT
#### Please note
> Please read this information carefully. You can run `./lnms dev:check` to check your code before submitting.
- [X] Have you followed our [code guidelines?](https://docs.librenms.org/Developing/Code-Guidelines/)
- [ ] If my Pull Request does some changes/fixes/enhancements in the WebUI, I have inserted a screenshot of it.
- [X] If my Pull Request makes discovery/polling/yaml changes, I have added/updated [test data](https://docs.librenms.org/Developing/os/Test-Units/).
#### Testers
If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, 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.
PipoCaninja has stated that he’d like to add this support using YAML instead of PHP. I tried, but can’t get it to work. My YAML is as following:
sensors:
sensors:
pre-cache:
data:
-
oid:
- entPhysicalVendorType
- entPhySensorOperStatus
- entPhysicalName
state:
data:
-
oid: entPhysicalName
value: entPhySensorOperStatus
num_oid: '1.3.6.1.2.1.99.1.1.1.5.{{ $index }}'
descr: entPhysicalName
states:
- { descr: In Operation, graph: 0, value: 1, generic: 0 }
- { descr: Failed, graph: 0, value: 3, generic: 2 }
# skip_values:
# -
# oid: entPhysicalVendorType
# op: '!='
# value: iso.3.6.1.4.1.47196.4.1.1.2.1.3
However, when running discovery nothing is found. Debug output doesn’t give me any clues.
Can someone help me converting my PHP code to YAML?
Hi @Tozz
You could try this :
sensors:
sensors:
pre-cache:
# data:
# -
# oid:
# - entPhysicalVendorType
# - entPhySensorOperStatus
# - entPhysicalName
state:
data:
-
oid: entPhySensorTable
value: entPhySensorOperStatus
num_oid: '1.3.6.1.2.1.99.1.1.1.5.{{ $index }}'
index: 'operStatus.{{ $index }}'
descr: '{{ $entPhysicalName }} status'
states:
- { descr: In Operation, graph: 0, value: 1, generic: 0 }
- { descr: Failed, graph: 0, value: 3, generic: 2 }
# skip_values:
# -
# oid: entPhysicalVendorType
# op: '!='
# value: iso.3.6.1.4.1.47196.4.1.1.2.1.3
And let us know how it goes.
The OID in the data structure is the table that contains the value, and the value is the exact data you want to gather.
You can try without the precache (cause if I remember well, any OID in the table is already precached, that is the advantage of doing that).
1 Like
Tozz
9 January 2024 09:40
3
I’ve tried the code below, but without any luck. Discovery finds nothing.
Also… I worry this might not work because of an IF-clause in the discovery code:
In includes/discovery/sensors/entity-sensor.inc.php there is a line:
// Check for valid sensors
if (isset($entry['entPhySensorOperStatus']) && ($entry['entPhySensorOperStatus'] === 'unavailable' || $entry['entPhySensorOperStatus'] === 'nonoperational')) {
$valid_sensor = false;
}
Unless I’m mistaken, this code would remove my PSU sensor when I pull the plug and thus remove any active alerts.
sensors:
state:
data:
-
oid: entPhysicalTable
value: entPhySensorOperStatus
num_oid: '1.3.6.1.2.1.99.1.1.1.5.{{ $index }}'
descr: entPhysicalName
group: 'Power supplies'
index: 'entPhySensorOperStatus.{{ $index }}'
states:
- { descr: 'ok', graph: 0, value: 1, generic: 0 }
- { descr: 'unavailable', graph: 0, value: 2, generic: 3 }
- { descr: 'nonoperational', graph: 0, value: 3, generic: 2 }
If you agree with me that the line in entity-sensor.inc.php would remove any PSUs with the cable pulled that were added using YAML discovery, perhaps it’s best that we go ahead with my PR that uses PHP code?
Hi @Tozz
This sensors tells you if the PowerSupply “sensor” can be obtained successfully. It does not give you the actual status of the power supply. So the code looks correct.
An object using this data type represents the operational status of a physical sensor. The value 'ok(1)' indicates that the agent can obtain the sensor value. The value 'unavailable(2)' indicates that the agent presently cannot obtain the sensor value. The value 'nonoperational(3)' indicates that the agent believes the sensor is broken. The sensor could have a hard failure (disconnected wire), or a soft failure such as out- of-range, jittery, or wildly fluctuating readings.
May be you are not trying to read correctly the sensor value here. PHP or YAML does not make a difference here.
Tozz
10 January 2024 12:42
5
Unfortunately that information seems to be incorrect for this specific switch. Here is a diff from the 2 snmpwalks. One with all PSUs okay and the other with the cord pulled on one of the PSUs:
> RFC1271-MIB::logDescription.301.4 = STRING: "|301|LOG_INFO|CDTR|1|PSU 1/2 changed state to Output Fault"
13073a13081
> RFC1271-MIB::logDescription.304.2 = STRING: "|304|LOG_ERR|CDTR|1|PSU 1/2 faulted. Total fault count: 1"
15947c15960
< ENTITY-SENSOR-MIB::entPhySensorOperStatus.107401 = INTEGER: ok(1)
---
> ENTITY-SENSOR-MIB::entPhySensorOperStatus.107401 = INTEGER: nonoperational(3)
16057c16070
< ENTITY-STATE-MIB::entStateOper.113002 = INTEGER: enabled(3)
---
> ENTITY-STATE-MIB::entStateOper.113002 = INTEGER: disabled(2)
The PSU was still physically in the device. So I did not remove the PSU itself. I only pulled the power cord.
Tozz
10 January 2024 12:47
6
Regardless, I’d prefer to stay with my PR Add PSU state sensor support for ArubaOS-CX & add serial and firmware by rudybroersma · Pull Request #15687 · librenms/librenms · GitHub as it is now with PHP code
If you could approve that PR I’d be grateful, I’ll start to work on the next one
All right, so this device is not implementing correctly the MIB. I’ll review the PHP variant in github.
Bye
system
Closed
9 April 2024 15:50
8
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.