Help with state mapping

Hello all,

i’m relatively new in using LibreNMS.

Our fresh installation works fine so far.
We are using it to monitor F5-Loadbalancers. As the default discovery for F5 does not monitor the Certificate-Expiration-Dates on the F5, we are trying to extend the discovery:

There is a ready to use Table for this in the F5-MIBs, which can be used by LibreNMS. It reports the Cert-Name as OID-Index and the expiration date in unix timstamp format (seconds since 01.01.1970)

But we are struggling with integration into the yaml file for F5. And we are not sure, whether it is possible to use just with the yaml.

Currently we tried to integrate it as a state sensor in includes/definitions/discovery/f5.yaml:

oid: sysCertificateFileObjectExpirationDate
num_oid: ‘.{{ $index }}’
descr: ‘{{ $index }}’
group: ‘Certificate expiration dates’
user_func: days_left
low_warn_limit: 30
low_limit: 5

This generates a list of all the certs installed on F5 in the State-Sensors group. So far, so good!

The user_func should substract the current timestamp from the one given from the F5 device and convert it into days. So it reports the days left until the cert is expired.

From the docs i understood, the low_… limits are for alerting only and not for state control. Correct?

Can i add state mapping which compares the days until expiration and mapps those to the generic values like this? (Well, abviously not, as discovery.php is complaining. But may be i am using a wrong syntax here?)

- { value: >=30, generic: 0, graph: 0, descr: ‘Good’}
- { value: <30, generic: 1, graph: 0, descr: ‘Warning’}
- { value: <5, generic: 2, graph: 0, descr: ‘Critical’}

Or do we have to integrate that check to the user_func, so this one will only return 0, 1 or 2? But then it woudn’t be possible to display the days left in the GUI, right?

Or are we taking the wrong direction and should instead use different sensor type or even build a PHP-Script for discovery?

Any ideas?

Thanks a lot in advance!