Getting "systemctl is-system-running" status

Hello,

On Linux hosts running systemd, we can have a global status of all services (as seen by systemd) using systemctl is-system-running.

The man page give 8 possible values:

Name Description
initializing Early bootup, before basic.target is reached or the maintenance state entered
starting Late bootup, before the job queue becomes idle for the first time, or one of the rescue targets are reached.
running The system is fully operational.
degraded The system is operational but one or more units failed.
maintenance The rescue or emergency target is active.
stopping The manager is shutting down.
offline The manager is not running. Specifically, this is the operational state if an incompatible program is running as system manager (PID 1).
unknown The operational state could not be determined, due to lack of resources or another error cause.

On a well configured host, the normal value must be “running” and a “degraded” value deserve an alert.

Sending this value through snmpd is easy, a small wrapper can give a numeric value to each different value if necessary.

Short term: is there a OID of a similar object I can use to make LibreNMS read, store and alert on this value? Or can I use a private OID for that and configure LibreNMS to use it? I don’t know where to search.

Long term: If it looks useful to others, how can this be added to LibreNMS?

For reference

It’s not exactly the same thing, but I just found librenms-agent/systemd.py at master · librenms/librenms-agent · GitHub