Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 7th October 2011, 13: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?

#!/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.
Reply With Quote
Sponsored Links
  #2  
Old 7th October 2011, 13:50
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,446
Thanks: 813
Thanked 5,216 Times in 4,089 Posts
Default

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
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting Email Working ISPConfig3 Squirrelmail and Courier etc Ian Wilson Installation/Configuration 17 19th June 2013 22:58
Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail-Problema jz_ HOWTO-Related Questions 9 14th September 2011 13:31
First IP OK, second IP times out Craig Installation/Configuration 12 10th June 2011 10:40
ffmpeg Video support for ubuntu 7.10 [suphp-ispconfig] amaurib Installation/Configuration 13 16th February 2010 17:26
MyDNS startup problem valter General 9 20th June 2009 17:31


All times are GMT +2. The time now is 06:51.


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