- Keeping the Server Alive!
- Posted by Josh Beck on November 21st, 2003
Ok, I have a question:
I want to write a script, or maybe a C program, or possibly use
a pre-existing application to do the following:
If I am gone for a week. I want the thing to periodically check
my ppp0 device to see if it is active. If the isp has gone down, and the
link has died, I would like the system to perform:
ifconfig ppp0 up
-Any ideas?
Thanks in advance
Josh Beck
--
- Posted by David Efflandt on November 21st, 2003
On Fri, 21 Nov 2003, Josh Beck <Webmaster@freewebspace.planetdns.net> wrote:
If you use demand pppd, ifconfig will not really tell you if it is
currently connected. So the best thing to do would be to set something in
a file from /etc/ppp/ip-up (or ip-up.local) when pppd connects (I use
local IP), and something else (I use zero) from /etc/ppp/ip-down so you
know when it disconnects.
Then by program or script run from crontab, you could check if ppp0 is up
from ifconfig output, and whether it is actually connected from contents
of the file you manipulate from ip-up|ip-down.
I run demand pppd (actually kernel pppoe) during boot (idle 0 to never
disconnect), and SETI@home which would trigger a connection at least once
a day when it uploads/downloads a work unit, if I was dropped
(disconnected) for some reason.
--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
- Posted by Captain Dondo on November 21st, 2003
David Efflandt wrote:
I have a problem where my pppd daemon stays up, but all connections
fail. This has something to do with multi-link pppd - my ISP and I have
not been able to track it down....
So, here's the script I use:
#!/bin/bash
# ping ISP every 10 minutes; if no answer, monitor pppd PIDs to see if
no change
..
# if no change in PIDs and no answer for 10 minutes, kill pppd.
HOST=isp.ip.x.x
SLEEPTIME=600
while [ true ] ; do
if [ `ping -w 10 -q -s 1024 -n $HOST | grep -c "100\% packet
loss"` == 1
] ; then
TEMP=`ps ax --format "%p %c" | grep " pppd$" | sed "s/
pppd/ /"`
sleep $SLEEPTIME
TEMP2=`ps ax --format "%p %c" | grep " pppd$" | sed "s/
pppd/ /"`
TEMP3=`ping -w 10 -q -s 1024 -n $HOST | grep -c "100\%
packet lo
ss"`
if [ "$TEMP" == "$TEMP2" ] && [ $TEMP3 == 1 ] ; then
killall pppd
fi
fi
sleep $SLEEPTIME
done
-Dondo
--
What am I on?
I'm on my bike, o__
6 hours a day, busting my ass. ,>/'_
What are you on? --Lance Armstrong (_)\(_)