Monitor linux services with check_mk or nagios plugins

Hi everyone,

I would like to moniotor some services (ufw, duplicati, …) on linux (debian 10) servers. I have both check_mk and nagios plugins intalled but I don’t know how to monitor a service like NT services with NSClient (by using option to tell what service I want to check). I juste want to know if the service is up or down. The check_service could be fine but there is no -H option so I don’t know how to use it remotely.

As far as I know, all check_mk/nagios plugins on linux are for a specific app/service. Correct me if I’m wrong.

What can I use to do so and if there is doc where can I find it?

King regards and thanks for your help

See my reply to this question: Checking the status of a process on Linux/Windows - #2 by JohnnyBBravo

Hi thanks!
It’s work great. Maybe few things: no need to put a clear password if you have done an ssh-copy-id with the monitored host before. And no need username if theire is a ssh_config file for librenms user. The script is more secure and shorter with this even if you have to do a bit of preconfiguration before :slight_smile:
And exit code WARNING and UNKNOWN are not used

#!/bin/bash
# Author: JP
# Check if service is running on remote machine using systemd

# Nagios exit codes
OK=0
WARNING=1
CRITICAL=2

# Arguments
HOSTNAME=$1
SERVICE=$2

if [[ -z $HOSTNAME ]];
then
    echo "Hostname is required"
    exit $WARNING
elif [[ -z $SERVICE ]];
then
    echo "Service is required"
    exit $WARNING
fi

ssh -T -q -o ConnectTimeout=10 $HOSTNAME "systemctl is-active $SERVICE"  > /dev/null
exitstatus=$?

if [[ $exitstatus -eq 0 ]];
then
    echo "OK: Service $SERVICE is running."
    exit $OK
else
    echo "CRITICAL: Service $SERVICE is not running!"
    exit $CRITICAL
fi

2 Likes