I am trying to add support for FiberStore datacenter switches (N5860 in my specific case). One odd thing I’ve run across is that the SFP optical power levels are split across two integer OIDs, like:
FS-FIBER-MIB::fsFiberRXpowerIntegerpart.1 = INTEGER: -2
FS-FIBER-MIB::fsFiberRXpowerDecimalpart.1 = INTEGER: 7
FS-FIBER-MIB::fsFiberRXpowerSign.1 = INTEGER: -1
for a value of -2.07. Is there a way to turn this into a single value for LibreNMS? I.e. fetch two values, do math (which is harder because the decimal part appears to be absolute), then treat as a single value for storage/graph use?
This is possible but not with YAML discovery, only using PHP code. You need to create a discovery and a poller code for your sensors, and impement the math here. Then the result will be saved as a single value in both DB and graphs.
Can you point me to any examples?
I don’t think we have this exact same situation (or did not find it) but you can start with these files :
In the discovery code, you can do all in one file and get the proper value into the
discover_sensor function. Of course, you won’t be able to put more than one OID. You will only put the main one, but this should not be a problem, cause you’ll also patch the polling code.
For the polling part:
- you can pre-cache the 2 missing OIDs (decimal and sign).
- in the polling file itself, you do the math with the 3 OID values, and put the result in the variable so it will get added automatically to the DB as well as the graphs.
Wow, what a terrible solution
You’ll need to do it in PHP since it is two different oids.
You might be able to do it with a user_func.
FYI, the normal way to handle this is, specify the value should be divided by 100 and:
FS-FIBER-MIB::fsFiberRXpower.1 = INTEGER: -207
(FS-FIBER-MIB::fsFiberRXpowerSign is completely useless since FS-FIBER-MIB::fsFiberRXpowerIntegerpart is already signed)