|
|
|
|
|
|
| Author |
Message |
Kevin Brown *nix forums beginner
Joined: 25 Feb 2005
Posts: 14
|
Posted: Fri Feb 11, 2005 8:46 pm Post subject:
PPP Script
|
|
|
I need to write a script which watches the logs and shows me when a
PPPoE connection fails. By going into the logs I can see all of the
times it has failed by typing:
cat /var/log/messages | grep terminated
But I want to use that as a trigger so that when a new line in the file
shows up with the word 'terminated', it will run another script which
will update the load balancing w/ the new PPP IP address.
Thanks in advance,
Kevin Brown. |
|
| Back to top |
|
 |
Bit Twister *nix forums Guru
Joined: 19 Feb 2005
Posts: 1546
|
Posted: Fri Feb 11, 2005 9:04 pm Post subject:
Re: PPP Script
|
|
|
On Fri, 11 Feb 2005 15:46:09 -0600, Kevin Brown wrote:
| Quote: | I need to write a script which watches the logs and shows me when a
PPPoE connection fails.
|
I would just ping the gateway myself.
| Quote: | By going into the logs I can see all of the
times it has failed by typing:
cat /var/log/messages | grep terminated
But I want to use that as a trigger so that when a new line in the file
|
Bad choice
| Quote: | shows up with the word 'terminated', it will run another script which
will update the load balancing w/ the new PPP IP address.
|
grep terminated /var/log/messages > /dev/null
if [ $? -eq 0 ] ; then
whatever you want to do here
fi |
|
| Back to top |
|
 |
Moe Trin *nix forums Guru
Joined: 20 Feb 2005
Posts: 972
|
Posted: Sat Feb 12, 2005 8:17 pm Post subject:
Re: PPP Script
|
|
|
In article <WG8Pd.22241$m22.503@read1.cgocable.net>, Kevin Brown wrote:
| Quote: | I need to write a script which watches the logs and shows me when a
PPPoE connection fails.
|
From: Mendel Cooper <thegrendel@theriver.com>
Newsgroups: comp.os.linux.announce
Subject: Advanced Bash Scripting Guide: ver. 3.2 update
Date: Thu, 10 Feb 2005 13:23:23 CST
Find that at any LDP mirror, or http://tldp.org/guides.html#abs
| Quote: | By going into the logs I can see all of the
times it has failed by typing:
cat /var/log/messages | grep terminated
|
We have another candidate for the 'Useless Use Of Cat' award!!! ;-)
Actually, a problem here - if 'terminated' shows up _anywhere_ in the
logs (here, /var/log/messages gets rotated weekly) it is found by grep.
| Quote: | But I want to use that as a trigger so that when a new line in the file
shows up with the word 'terminated', it will run another script which
will update the load balancing w/ the new PPP IP address.
|
while true ; do
NOW=`date +"%d %H:%M"`
grep "$NOW" /var/log/messages | grep -q terminated
if [ $? = "0" ] ; then
run.other.script
fi
sleep 30
done
See also the man pages. Briefly, endless loop, which assigns the current
day of month (%d), a space, and the time in hours/minutes to the variable
'NOW'. The next line then greps for that in /var/log/messages (the quouts
around the variable protect the space it contains) to get messages for the
current minute, and passes that to a quiet grep (no output needed) for the
desired word. If the word is found, run your script. Then sleep for 30 seconds
and repeat endlessly.
The thing is, there is (quoting Larry Wall) "more than one way to do it".
You might also look at /etc/ppp/ip-down, and see if that is being run when
the link fails - and run a restart out of there.
Old guy |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Fri Jan 09, 2009 8:39 am | All times are GMT
|
|
Loans | RC51 | Credit Score | Notebook Deals | Loans
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|