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 am new to the forum, as well as new to Nagios. I am trying to bring myself up to speed, but I can't seem to figure one thing out. I am having some problems getting iptables to return data to the Nagios server. I found a script posted to this exchange and created my own plugin, which looks like this:
#!/bin/bash
IPT='sudo /sbin/iptables'
GREP='/bin/grep'
AWK='/bin/awk'
EXPR='/usr/bin/expr'
WC='/usr/bin/wc'
STAT=0
OUTPUT=''
CHAINS=`$IPT -nvL | $GREP 'Chain' | $AWK '{ print $2 }'`
for CHAIN in $CHAINS ; do
if [ "$CHAIN" != 'FORWARD' ] && [ "$CHAIN" != 'OUTPUT' ] && [ `$EXPR substr $CHAIN 1 4` != "LOG_" ] ; then
CNT=`expr $($IPT -L $CHAIN | $WC -l) '-' 1`
if [ $CNT -eq 0 ] ; then
OUTPUT="<b>${OUTPUT}ERROR $CHAIN $CNT rules!</b><br>"
STAT=2
else
OUTPUT="${OUTPUT}OK $CHAIN $CNT rules<br>"
fi
fi
done
echo $OUTPUT
exit $STAT
From there I added an entry to the nrpe.cfg file which looks like this: command[check_iptables]=/usr/lib64/nagios/plugins/check_iptables, When I run this command from the command-line, I get an appropriate response. When I check the Nagios GUI, the iptables command shows up as grenn/OK, but the status field says "CHECK_NRPE: No output returned from daemon".
Does anyone have any suggestions or insight into getting iptables to be monitored correctly?
Log on to the remote server and su - nagios then run the script... I reckon it doesn't have permissions to execute one of the bins (I'm tipping iptables) do you have the nagios user in the sudoers file to allow it to sudo iptables without a password?
jsmurphy wrote:I reckon this is probably a permissions issue...
Log on to the remote server and su - nagios then run the script... I reckon it doesn't have permissions to execute one of the bins (I'm tipping iptables) do you have the nagios user in the sudoers file to allow it to sudo iptables without a password?
I have the following entry in my sudoers file: nagios ALL= NOPASSWD: /sbin/iptables
Usually these problems are permission problems or NRPE problems. Do you have NRPE set up and working correctly with other plugins? Does your plugin work if it's run directly by Nagios rather than through NRPE?