IPtables check not returning data
Posted: Thu Jun 07, 2012 1:51 pm
Hi
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:
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?
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:
Code: Select all
#!/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
Does anyone have any suggestions or insight into getting iptables to be monitored correctly?