Option to monitor or check custom made services in Ubuntu

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

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

Post 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)?
Be sure to check out our Knowledgebase for helpful articles and solutions!
epixelitsupport
Posts: 85
Joined: Fri Nov 08, 2019 2:40 am

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

Post by epixelitsupport »

output when it is not running: https://prnt.sc/qcmppy

When it is running: https://prnt.sc/qcmr34
Attachments
servicescript.sh
scriptfile
(86 Bytes) Downloaded 133 times
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
epixelitsupport
Posts: 85
Joined: Fri Nov 08, 2019 2:40 am

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

Post by epixelitsupport »

Worked !!! Thanks, A lot
Locked