Page 5 of 5

Re: Option to monitor or check custom made services in Ubunt

Posted: Wed Dec 18, 2019 10:17 am
by lmiltchev
Can you post the latest version of your script on the forum?

When you run the script locally on the client, and then run:

Code: Select all

echo $?
what is the output that you see (when the "cmmt_revolution" is running and when it is stopped)?

Re: Option to monitor or check custom made services in Ubunt

Posted: Wed Dec 18, 2019 10:38 am
by epixelitsupport
output when it is not running: https://prnt.sc/qcmppy

When it is running: https://prnt.sc/qcmr34

Re: Option to monitor or check custom made services in Ubunt

Posted: Wed Dec 18, 2019 12:20 pm
by scottwilkerson
Looking at the script it was not capturing the proper exit code of the systemctl command

If you modify to the following you should get the desired results

Code: Select all

#!/bin/bash

status=$(systemctl status cmmt_revolution)
exitcode=$?
echo "$status" | tr -cd '\11\12\15\40-\176'

if [ $exitcode -eq 0 ]; then
    exit 0
else
    exit 2
fi
As a FYI, a general rule of thumb support on this forum should be related to Nagios Core, debugging your custom scripts is not within the scope of Nagios project support

Re: Option to monitor or check custom made services in Ubunt

Posted: Wed Dec 18, 2019 1:08 pm
by epixelitsupport
Worked !!! Thanks, A lot