My systemd check is not working

Hi all,

I have Xeams, 3CX running on Linux servers and wish to check the service statusses.
systemd check in Linux are working and I found the following script GitHub - melmorabity/nagios-plugin-systemd-service: Nagios plugin to check the status of a systemd service

I’ve installed the agent-setup on my Xeams and 3CX servers by following this manual:

And copied the check_systemd_service.sh to the /usr/lib/check_mk_agent/local folder and applied the chmod x command.

When I execute the script against the service. The returned result is that the service is running.
e.g. ./usr/lib/check_mk_agent/local/check_systemd_service xeams
OK: service xeams is running

Yet on my Librenms server the service is not checking (or returning the result) of my service. It only states “Usage: check_systemd_service”.

Used service:
image

Testing with different parameters are not working.
I’ve tried Xeams, xeams, ./check_systemd_service xeams, ./check_systemd_service.sh xeams, ./usr/lib/check_mk_agent/local/check_systemd_service xeams, …

Any ideas?
Pretty new to the whole Librenms system, so might be an oversight on my part.

Thx!

The services are nagios plugins only so you’d need to find a nagios plugin which does what you want.

I can maybe expand on that a bit…

Service checks run on the LibreNMS poller itself. So if you used check_http for example, with an IP address of 192.168.2.22, all the poller does is locally run something like check_http -H 192.168.2.22. If you need to add something to that command, like if you’re checking http on port 8080 instead of 80, you would add in -p 8080 in the parameters field. Not the whole command.

From what I can tell, check_systemd_service.sh can only check services on a local machine; no remote check option. So for that to work you need some way of running the script on the remote machine and pulling the data back to LibreNMS (like NRPE or check_by_ssh).

Like you, I’ve got the check_mk agent running on my remote Linux servers so I’ve been playing with this (it’s experimental). But it allows you to use the check_mk agent to execute the local script and get it to LibreNMS via MRPE.

If you’re interested in that, on your Xeams server, you might add something like…

XEAMS /usr/lib/nagios/plugins/check_systemd_service.sh xeams

…to: /etc/check_mk/mrpe.cfg

Then you would download that check_mrpe file into your LibreNMS server’s nagios plugins location (usually
/usr/lib/nagios/plugins) and chmod +x it.

That should give you a mpre option in add services. Use that and set the IP address to the address of your Xeams server and set the parameters to -a XEAMS

So if I understand it correctly.

  1. Download and install the check_mrpe application on my Xeams server
  2. Add the code XEAMS /usr/lib/nagios/plugins/check_systemd_service.sh xeams to /etc/check_mk/mrpe.cfg on my Xeams server
  3. Download and add the code of librenms check_mrpe to my librenms server it’s /usr/lib/nagios/plugins folder

Correct?

No need for step 1. check_mpre only needs to be on the LibreNMS server. The check_mk agent needs to be on your Xeams server before you can do step 2 but I think you’ve got that already.

Bit stuck, where could I download the check_mk agent?
The command apt-get install check_mk_agent is not doing much. Nor does the check_mk site explains where you can fetch it from.

https://docs.librenms.org/#Extensions/Agent-Setup/

If you did those steps on the Xeams servers the check_mk agent should be installed. You can check it by running…

telnet [xeam_server_ip] 6556
…or…
nc --recv-only [xeam_server_ip] 6556

…from your LibreNMS server. It should dump a stream of statistics about the server if it’s working.

The agent is installed and running.
afbeelding

So now I to add the code
XEAMS /usr/lib/nagios/plugins/check_systemd_service.sh xeams

to
/etc/check_mk/mrpe.cfg

On my Xeams or LibreNMS server?

Then add the check_systemd_service.sh to my LibrenNMS server
/usr/lib/nagios/plugins

Correct?

Both mrpe.cfg and the check_systemd_service.sh script would be on the Xeams server. What this does is it runs check_systemd_service.sh locally on your Xeams server and adds its output under <<<mrpe>>> in the check_mk agent’s output.

Then, the LibreNMS server reads this with the check_mpre script as a service.

1 Like