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.
i had a problem with the check of the code below.
The code has the name firewall_check.sh on the client.
When i run firewall_check.sh on the client it works correctly (it says running or not running).
#!/bin/bash
SERVICE=firewall;
status="/etc/init.d/$SERVICE status"
if $status | grep "firewall is running"; then
echo "Status 0 - OK : $service is running"
elif $status | grep "firewall is stopped"; then
echo "Status 1 - Critical : $service is not running"
else
echo "Status 2 - Information : $service is unrecognized service"
fi
When i run firewall_check.sh on the client it works correctly (it says running or not running).
Do you run the check as root or as nagios user? Can you show us the actual check run as nagios from the command line, along with the output of it? Also, show us how the check is defined in the nrpe.cfg. I suspect you will need to add the command to the sudoers.
Be sure to check out our Knowledgebase for helpful articles and solutions!
#!/bin/bash
SERVICE=firewall;
status="/etc/init.d/$SERVICE status"
if $status | grep "firewall is running"; then
echo "Status 0 - OK : $SERVICE is running"
elif $status | grep "firewall is stopped"; then
echo "Status 1 - Critical : $SERVICE is not running"
else
echo "Status 2 - Information : $SERVICE is unrecognized service"
fi
#!/bin/bash
SERVICE=firewall;
T1=$(sudo /etc/init.d/$SERVICE status)
RUNNING="$SERVICE is running"
STOPPED="$SERVICE is stopped"
UNKNOWN="$SERVICE is unknown"
if [ "$T1" = "$RUNNING" ]; then
echo "Status 0 - OK : $RUNNING"
exit 0
elif [ "$T1" = "$STOPPED" ]; then
echo "Status 1 - Critical : $STOPPED"
exit 2
else
echo "Status 2 - Information : $UNKNOWN - $T1"
exit 3
fi
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.