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
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
#!/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.
I’m wondering this too, and not finding much information. I found the mibs I need, but I don’t know how to query them with LibreNMS. I found a processes table in the database, but it is empty. Anyone know how to populate it?