Page 1 of 1

help for custom monitoring check on unix

Posted: Thu Feb 18, 2021 9:29 am
by selia04
Good morning everyone,

We need to execute this remote custom command on a server to check if a service is alive: (this process not appears in the discovered services of this Linux and is not detected by Nagios) so we can't use the standard check_xi_service_snmp_linux_process! , the command we need to execute the remote server is:

(lsnrctl status | grep -A1 "owbservice" | grep READY) >/dev/nullĀ  && echo OWB ACTIVE

This server had nrpe (unix) client installed ; and that if it returns a blank value it generates Critical alert and if it returns "OWB ACTIVE" it is OK and no alert.

how should this be implemented step by step? (for dummies) The nrpe client is already installed on the client machine, but I am not familiar with Nagios for this type of check.

Best Regards

Re: help for custom monitoring check on unix

Posted: Thu Feb 18, 2021 6:40 pm
by ssax
To help you get started you can use this:

Code: Select all

#!/bin/bash
$((lsnrctl status | grep -A1 "owbservice" | grep READY) >/dev/null)
STATUS=$?
if [[ $STATUS -ne 0 ]]; then
        echo 'CRITICAL - Not running!'
        exit 2
else
        echo 'OK - OWB ACTIVE'
        exit 0
fi
One thing I would mention is that if the commands aren't in the standard paths you should use the full path to the binaries/commands or do something like this to find the bin before you run it:

Code: Select all

#!/bin/bash
LSNRCTLBIN=$(which lsnrctl)
$(($LSNRCTLBIN status | grep -A1 "owbservice" | grep READY) >/dev/null)
STATUS=$?
if [[ $STATUS -ne 0 ]]; then
        echo 'CRITICAL - Not running!'
        exit 2
else
        echo 'OK - OWB ACTIVE'
        exit 0
fi
Please note that helping you write custom plugins isn't included as a part of support and falls into the custom development/consulting area.

For any future plugins/changes you can follow the documentation below OR look at some of the other plugins in /usr/local/nagios/libexec to see how they are written to help you further:

https://assets.nagios.com/downloads/nag ... inapi.html

https://nagios-plugins.org/doc/guidelines.html

We do offer paid custom development/consulting, if that is something you're interested in you can contact [email protected] (or call them) to get more information/a quote.

Thank you!