View Single Post
Old 7th October 2011, 14:37
duster duster is offline
Junior Member
Join Date: Jun 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Monitoring Linux service and Interface

Can some assist me in creating a script that does this. Monitor Eth0 & Eth1 and httpd service. If interface Etho or Eth1 doesn't respond to pings for 5 minutes, the server should do a shutdown. Also if the httpd service isnt running or stopped for any reason shut the machine off. So basically any of these conditions will initiate a poweroff. Thanks

This is what ive done so far . Im still missing the ping section. Is what i'm doing correct?


Inter0=`/sbin/ifconfig | grep eth0 | awk '{print $1}'`
Inter1=`/sbin/ifconfig | grep eth1 | awk '{print $1}'`

if ps ax | grep -v grep | grep $SERVICE > /dev/null


echo "$SERVICE service running"


sleep 30s
shutdown -h now


if [ -z $inter0]; then
sleep 30s
shutdown -h now


if [ -z $Inter1]; then

sleep 30s
shutdown -h now


Last edited by duster; 7th October 2011 at 15:16.
Reply With Quote
Sponsored Links