Thought this might be useful to someone.
Currently this script works on centos based installs.
I did not write this originally so not attempting to take the credit for whom-ever did ..
I have this scheduled every 5 mins on other asterisk boxes.
Will be attempting to modify this for my viciBox cluster
***********
#!/bin/bash
DIR_PATH="/tmp/fwscript"
FILE="/var/log/fwstatus"
CHK="$DIR_PATH/chkfile"
MAILPROG="/bin/mail"
SUBJECT="IPTables service is OFF on $HOSTNAME"
EMAIL="put-your-email-here@yourdomain.com"
/sbin/service iptables status | if grep ESTABLISHED 1> /dev/null 2> /dev/null
then
rm -f $CHK
/bin/echo "Firewall Running on Server"
else
echo `date` | tee $FILE
echo | tee -a $FILE
echo "Firewall not Running" | tee -a $FILE
echo | tee -a $FILE
echo "Starting a Firewall Service" | tee -a $FILE
echo | tee -a $FILE
/sbin/service iptables start |tee -a $FILE
echo | tee -a $FILE
echo | tee -a $FILE
if test $? = 0
then
echo "Firewall was started sucessfully" | tee -a $FILE
else
echo "Firewall failed to start" | tee -a $FILE
fi
echo "Now sending mail"
$MAILPROG -s "$SUBJECT" "$EMAIL" < $FILE
echo "Creating CHK File"
touch $CHK
fi
***********