HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Programming/Scripts (http://www.howtoforge.com/forums/forumdisplay.php?f=7)
-   -   Monitoring Linux service and Interface (http://www.howtoforge.com/forums/showthread.php?t=54471)

duster 7th October 2011 14:37

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

till 7th October 2011 14:50

I think you could do this with monit and munin without having to create your own scripts. Falko has published several tutorials on that topic here on howtoforge. E.g. this one for debian:

http://www.howtoforge.com/server-mon...n-debian-lenny


All times are GMT +2. The time now is 20:57.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.