Networking Forums

Networking Forums > Computer Networking > Linux Networking > PPP Script

Reply
 
 
Kevin Brown
Guest
Posts: n/a

 
      02-11-2005, 08:46 PM
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.
 
Reply With Quote
 
 
 
 
Bit Twister
Guest
Posts: n/a

 
      02-11-2005, 09:04 PM
On Fri, 11 Feb 2005 15:46:09 -0600, Kevin Brown wrote:
> 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.

> 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

> 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
 
Reply With Quote
 
Moe Trin
Guest
Posts: n/a

 
      02-12-2005, 08:17 PM
In article <WG8Pd.22241$(E-Mail Removed)>, Kevin Brown wrote:

>I need to write a script which watches the logs and shows me when a
>PPPoE connection fails.


From: Mendel Cooper <(E-Mail Removed)>
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

>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.

>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
 
Reply With Quote
 
 
 
Reply

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy files using filenames from text files with shell script or bash script altariamx2003@gmail.com Linux Networking 4 11-23-2006 08:27 AM
Need for one script Suresh.T Linux Networking 1 10-23-2006 04:43 PM
Initialization script and ssh Christian Christmann Linux Networking 8 10-09-2006 11:20 PM
Logon script =?Utf-8?B?RGF2ZQ==?= Windows Networking 4 04-22-2004 11:56 PM
login script over VPN? Jason Wilder Windows Networking 4 04-16-2004 02:28 AM



1 2 3 4 5 6 7 8 9 10 11