niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » Linux » networking
PPP Script
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
Kevin Brown
*nix forums beginner


Joined: 25 Feb 2005
Posts: 14

PostPosted: Fri Feb 11, 2005 8:46 pm    Post subject: PPP Script Reply with quote

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

PostPosted: Fri Feb 11, 2005 9:04 pm    Post subject: Re: PPP Script Reply with quote

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

PostPosted: Sat Feb 12, 2005 8:17 pm    Post subject: Re: PPP Script Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Fri Jan 09, 2009 8:39 am | All times are GMT
navigation Forum index » *nix » Linux » networking
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts does squid 2.6 support setting cache_peer port in redirec... Victor Tsang Squid 0 Fri Jul 21, 2006 8:16 am
No new posts mail script eeb4u@hotmail.com shell 3 Fri Jul 21, 2006 5:50 am
No new posts A simple bash script JPB Suse 2 Fri Jul 21, 2006 2:19 am
No new posts Getting started in PXPerl, i.e how to run a script? Markus Hänchen Perl 5 Thu Jul 20, 2006 2:12 pm
No new posts Match pattern in ksh script lnrntx@gmail.com shell 6 Thu Jul 20, 2006 1:48 am

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
[ Time: 4.1640s ][ Queries: 16 (3.9893s) ][ GZIP on - Debug on ]