Checking the status of a process on Linux/Windows

Hi,

is it possible in LibreNMS to check the status of a process which is either running on Linux or Windows. I set up services but it is quite what I am looking for, because I am limited to services like smtp, imap, ssh, mysql etc…

What I am looking for is to specifically check if a process is running or dead. For example I want to check if the NUT client, to shutdown the server if the UPS has less than 50% battery, is running on my windows machine.

I searched quite a bit but I couldn’t find anything regarding that topic. It usually all comes back to setting up services. Nagios offers process checks which are possible via SNMP. Process Checks

Also read on OpenNMS that is possible to check process status via SNMP. Process Monitoring with SNMP – The OpenNMS Group, Inc.

Any idea if that is possible in LibreNMS?

Thanks so much :slight_smile:

On Linux that’s not so difficult to do with a Nagios plugin.
I’ve written the script below that will use ssh to login to a machine and issue the “systemctl is-active” command followed by the name of the service you want to check.

I’m a total noob at bash scripting so the code might be crappy, but for me it works :slight_smile:

#!/bin/bash

# Author: JP
# Check if service is running on remote machine using systemd

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

# Arguments
HOSTNAME=$2
USERNAME=$3
PASSWD=$4
SERVICE=$5

if [[ -z $HOSTNAME ]];
then
    echo "Hostname is required"
    exit $CRITICAL
fi
if [[ -z $USERNAME ]];
then
    echo "Username is required"
    exit $CRITICAL
fi
if [[ -z $PASSWD ]];
then
    echo "Password is required"
    exit $CRITICAL
fi
if [[ -z $SERVICE ]];
then
    echo "Service is required"
    exit $CRITICAL
fi

# Check if sshpass is installed, if not then exit with error message
command -v sshpass >/dev/null || { echo "Dependency sshpass not installed on the LibreNMS server"; exit $CRITICAL; }

sshpass -p "$PASSWD" ssh -T -q -o StrictHostKeyChecking=no -o ConnectTimeout=10 [email protected]$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

As you can see in the code it is required to have “sshpass” installed on your LibreNMS machine.
I have saved the script as “check_service” in the appropriate nagios plugin directory.

Then add the service to the host you’re monitoring with the username / password / service as the parameters.
PS. In the example I’m checking the “Chrony” service.

Don’t ask me how you can do this on a windows machine though, I don’t know anything about windows :wink:

Is there anyway to use SNMP instead of ssh?

Since it is possible to check the status of a service with SNMP.

OpenNMS offers such a solution that you can monitor the status of a process via SNMP.

Is it possible to access these informations in LibreNMS? Process Monitoring with SNMP – The OpenNMS Group, Inc.