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?
#!/bin/sh
SERVICE='httpd'
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
then
echo "$SERVICE service running"
else
sleep 30s
shutdown -h now
fi
if [ -z $inter0]; then
sleep 30s
shutdown -h now
fi
if [ -z $Inter1]; then
sleep 30s
shutdown -h now
exit
Last edited by duster; 7th October 2011 at 14:16.
|
Recent comments
11 hours 6 min ago
14 hours 2 min ago
15 hours 16 min ago
16 hours 39 min ago
18 hours 17 min ago
19 hours 46 min ago
20 hours 59 min ago
1 day 12 hours ago
1 day 13 hours ago
1 day 17 hours ago