(OS: Debian 11)
I have a problem with the dashboard, one of my personalized sensors remains always green, even in critical condition.
I will describe to you what I did:
Usually I use the default sensors or downloads from the official website. But this time, I launched a script.sh to find out if the bind9 DNS service is active or inactive.
Here it is and it works :
---------------------------------------------------------------------------------
Code: Select all
#!/bin/bash
if systemctl is-active --quiet bind9; then
echo "OK - The Bind9 service is active."
exit 0 # Exit code 0 for OK
else
echo "CRITICAL - The Bind9 service is down."
exit 2 # Exit code 2 for CRITICAL
fi
I put it on my client, I put the execution rights and declare it in /etc/nagios => nrpe.cfg
I tested it on my nagios (server side), in /usr/local/nagios/libexec: with "NRPE" =>
Code: Select all
./check_nrpe -H xxx.xxx.xxx.xxx -c check_status_bind9
I declared my sensor in the "commands.cfg" file in /usr/local/nagios/etc/objects.
Here is the line from this file:
Code: Select all
## DNS service
define command{
command_name check_status_dns
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ check_status_bind9
}
Code: Select all
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
But, when I voluntarily turn off my DNS, in order to create "critical" on the dashboard, nothing happens, it always remains green.
However, the output of my script when everything is fine is: 0 and when it is an error it is: 2
In theory nagios, takes the 2 which for him means "error".
I don't know if I need to add options somewhere, I tried a lot of other configs but without success. I also thought about putting " -w $ARG1$ -c $ARG2$ " in " define command " without success.
If you have any ideas, I'm interested.
Thank you.