Re: Monitoring linux services through systemd

James Zuelow <[email protected]>
Newsgroups gmane.network.opennms.general
Message-ID <[email protected]>
I'm sure there is a better way to do this, but while you wait for a more elegant solution you could set up a script that checks the status of the services you're interested in.  Write the script so that the output is a number, where running is 0, and degraded is some higher non-zero value (say 2).  (It depends on how many different statuses you're interested in.)

To use the script add an exec line in snmpd.conf, and then poll that with SNMP.

Use oid .1.3.6.1.4.1.2021.8.1.100, and the "instance" number is the positional reference to where your script is located in snmpd.conf.

For example if you have in snmpd.conf:

exec   Service1Status   /bin/bash /usr/local/bin/systemctl-status-service1.sh
exec   Service2Status /bin/bash /usr/local/bin/systemctl-status-service2.sh

Then make a custom group in opennms/datacollection.
In our example, the output of systemctl-status-service1.sh will show here:

<mibObj oid=".1.3.6.1.4.1.2021.8.1.100"  instance="1"  alias="Service1Status"  type="integer32" />

And the output of systemctl-status-service2.sh will show here:

<mibObj oid=".1.3.6.1.4.1.2021.8.1.100"  instance="2"  alias="Service2Status"  type="integer32" />


Once you're collecting data, set a threshold on the OID to where it sends a notification when the value meets your degraded threshold.

Again, this isn't exactly integrating systemd statuses into SNMP.  It's just a quick & dirty way of setting up an SNMP threshold that will trigger when the services you're interested go into degraded status.

James

From: JohnD Blackburn [mailto:[email protected]]
Sent: Wednesday, May 9, 2018 7:32 PM
To: General OpenNMS Discussion
Subject: [opennms-discuss] Monitoring linux services through systemd

Has anyone set up monitoring of Linux services listed in systemd?


What I want to be able to do is to alert when specific services are "degraded"

$ systemctl list-units
UNIT                                                        LOAD   ACTIVE SUB       DESCRIPTION
....
network.service                                             loaded active running   LSB: Bring up/down networking
NetworkManager-wait-online.service                          loaded active exited    Network Manager Wait Online
NetworkManager.service                                      loaded active running   Network Manager
oddjobd.service                                             loaded active running   privileged operations for unprivileged applications


Is there something already in OpenNMS that does this/achieves the same result which I have missed/overlooked?

It looks like systemd status has not been integrated into net-snmp so would need a method to access that info from the opennms server.

It is possible to enable dbus to listen on a tcp port, and to query it remotely, however, there are possibly security considerations when doing this.

Regards,
John Blackburn

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-discuss mailing list

To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-discuss
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.