Nagios run a script on Red Hat box

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Nagios run a script on Red Hat box

Post by jkinning »

I have a Red Hat LInux server being monitored with Nagios by nrpe. I have a script that needs to be ran and then if the Expect output is "shnlp-syslog-service is running" everything is good. If when the script is ran and anything else is returned I need a notification to be sent saying something like "Skyhigh is not getting logs! Skyhigh logging service is stopped". Is this possible with Nagios XI and if so what is the best way to go about setting a check like this up?
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Nagios run a script on Red Hat box

Post by rkennedy »

It sounds like you need to write up a plugin to do so. Take a look at one I wrote, that could be modified for your need - https://github.com/rcknag/nagios-plugin ... ocalnfs.sh

Specifically, this part -

Code: Select all

count=$(/usr/bin/timeout 10 /usr/local/nagios/libexec/check_disk -w 10 -c 20 -p "$path" | wc -l)
You can evaluate based on how many lines the response is, and then you would need to exit #(where # is the number to exit on)

In nagios, 0 = OK, 1 = WARNING, 2 = CRITICAL, and 3 = UNKNOWN. These are what Nagios uses to relay what the status is.

https://nagios-plugins.org/doc/guidelines.html is a good reference to use for understanding the plugin guidelines.
Former Nagios Employee
Locked