I've written a korn script (viagrad) that runs as a daemon and checks
that my ADSL router is up. If no hosts beyond the router are pingable,
it resets (via expect scripts) the username in the router to the telco's
default, then waits a while for a re-train on the gateway, reboots the
router, resets the account to my user account, and starts the loop
again.


In the script I have:

this=$(basename ${0})
syslog="logger -t ${this}"

..
....
ping_hosts()
{
..
..
                # if our router is not connected to the Internet, then log so
                if [[ ${notified} = 'false' ]]; then

                        ${syslog} 'link down!'
                        send_mail 'down!'
                        notified='true'
                fi

..
..
..


reboot_router()
{
        ${syslog} "rebooting ${router}"
        $(dirname ${0})/reboot/${router_connect}

        # Give the router a chance to reboot & retrain
        sleep ${reboot_sleep}
        ping_router
}

reset_line()
{
        ${syslog} "line reset with account: ${1}"
        $(dirname ${0})/reset/${router_connect} ${1}

        # Give the router a chance to retrain on the ADSL gateway
        sleep ${retrain_sleep}
        ping_router
}



..
....

The router's DNS name is juniper, and the host that this runs on is
teak, but notice the time stamps from the script are delayed, compared
to the syslog events from the router:

Jun 28 12:41:05 juniper juniper: board 0 line 0 channel 0, call 8, C02 Call 
Terminated 
Jun 28 12:42:13 juniper juniper: ppp:LCP Closing

LATE:
Jun 28 12:40:09 teak viagrad: link down!
Jun 28 12:43:22 juniper juniper: ppp:IPCP Closing
Jun 28 12:44:30 juniper juniper: board 0 line 0 channel 0, call 9, C01 Outgoing 
Call dev=5 ch=0  
Jun 28 12:45:38 juniper juniper: board 0 line 0 channel 0, call 9, C02 OutCall 
Connected 512000  
Jun 28 12:46:46 juniper juniper: ppp:LCP Starting
Jun 28 12:47:54 juniper juniper: ppp:LCP Opening
Jun 28 12:49:02 juniper juniper: ppp:CHAP Shutdown
Jun 28 12:50:10 juniper juniper: ppp:LCP Closing

LATE:
Jun 28 12:43:10 teak viagrad: line reset with account: [EMAIL PROTECTED]
Jun 28 12:51:18 juniper juniper: board 0 line 0 channel 0, call 9, C02 Call 
Terminated 
Jun 28 12:52:26 juniper juniper: board 0 line 0 channel 0, call 10, C01 
Outgoing Call dev=5 ch=0  
Jun 28 12:53:34 juniper juniper: board 0 line 0 channel 0, call 10, C02 OutCall 
Connected 512000  

LATE:
Jun 28 12:43:54 teak viagrad: rebooting branch.juniper
Jun 28 12:54:42 juniper juniper: ppp:LCP Starting
Jun 28 12:55:50 juniper juniper: ppp:LCP Opening
Jun 28 12:56:58 juniper juniper: ppp:CHAP Shutdown
Jun 28 12:58:06 juniper juniper: ppp:LCP Closing

LATE:
Jun 28 12:45:29 teak viagrad: line reset with account: [EMAIL PROTECTED]
Jun 28 12:59:14 juniper juniper: board 0 line 0 channel 0, call 10, C02 Call 
Terminated 
Jun 28 13:00:22 juniper juniper: board 0 line 0 channel 0, call 11, C01 
Outgoing Call dev=5 ch=0  
Jun 28 13:01:30 juniper juniper: board 0 line 0 channel 0, call 11, C02 OutCall 
Connected 512000  
Jun 28 13:02:39 juniper juniper: ppp:LCP Starting

LATE:
Jun 28 12:49:33 teak viagrad: rebooting branch.juniper
Jun 28 13:03:47 juniper juniper: ppp:LCP Opening
Jun 28 13:04:55 juniper juniper: ppp:CHAP Shutdown
Jun 28 13:06:03 juniper juniper: ppp:LCP Closing

LATE:
Jun 28 12:54:31 teak viagrad: line reset with account: [EMAIL PROTECTED]
Jun 28 13:07:11 juniper juniper: board 0 line 0 channel 0, call 11, C02 Call 
Terminated 

LATE:
Jun 28 12:55:14 teak viagrad: rebooting branch.juniper
Jun 28 13:08:19 juniper juniper: board 0 line 0 channel 0, call 12, C01 
Outgoing Call dev=5 ch=0  

LATE:
Jun 28 12:56:49 teak viagrad: line reset with account: [EMAIL PROTECTED]
Jun 28 13:09:27 juniper juniper: board 0 line 0 channel 0, call 12, C02 OutCall 
Connected 512000  
Jun 28 13:10:35 juniper juniper: ppp:LCP Starting
Jun 28 13:11:05 juniper juniper: ppp:LCP Opening
Jun 28 13:11:05 juniper juniper: ppp:LCP Closing
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 12, C02 Call 
Terminated 

LATE:
Jun 28 13:00:54 teak viagrad: rebooting branch.juniper
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 13, C01 
Outgoing Call dev=5 ch=0  

LATE:
Jun 28 13:05:51 teak viagrad: line reset with account: [EMAIL PROTECTED]
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 13, C02 OutCall 
Connected 512000  

LATE:
Jun 28 13:06:34 teak viagrad: rebooting branch.juniper
Jun 28 13:11:05 juniper juniper: ppp:LCP Starting

LATE:
Jun 28 13:08:10 teak viagrad: line reset with account: [EMAIL PROTECTED]


ISP's RADUIS server goes a bit spazzo as everyone tries to re-auth after
the brown-out:


Jun 28 13:11:05 juniper juniper: ppp:LCP Opening
Jun 28 13:11:05 juniper juniper: ppp:CHAP Opening
Jun 28 13:11:05 juniper juniper: ppp:IPCP Starting
Jun 28 13:11:05 juniper juniper: ppp:IPCP Opening
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 9, C01 Outgoing 
Call dev=5 ch=0  
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 9, C02 OutCall 
Connected 512000  
Jun 28 13:11:05 juniper juniper: ppp:LCP Starting
Jun 28 13:11:05 juniper juniper: ppp:LCP Opening
Jun 28 13:11:05 juniper juniper: ppp:CHAP Opening
Jun 28 13:11:05 juniper juniper: ppp:IPCP Starting
Jun 28 13:11:05 juniper juniper: ppp:IPCP Opening
Jun 28 13:11:05 juniper juniper: ppp:LCP Closing
Jun 28 13:11:05 juniper juniper: ppp:IPCP Closing
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 9, C02 Call 
Terminated 
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 10, C01 
Outgoing Call dev=5 ch=0  
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 10, C02 OutCall 
Connected 512000  
Jun 28 13:11:05 juniper juniper: ppp:LCP Starting
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 10, C02 Call 
Terminated 
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 11, C01 
Incoming Call 1500000  
Jun 28 13:11:05 juniper juniper: ppp:LCP Opening
Jun 28 13:11:05 juniper juniper: ppp:CHAP Shutdown
Jun 28 13:11:05 juniper juniper: ppp:LCP Closing
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 11, C02 Call 
Terminated 
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 12, C01 
Outgoing Call dev=5 ch=0  
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 12, C02 OutCall 
Connected 512000  
Jun 28 13:11:05 juniper juniper: ppp:LCP Starting
Jun 28 13:11:05 juniper juniper: ppp:LCP Opening
Jun 28 13:11:05 juniper juniper: ppp:CHAP Shutdown
Jun 28 13:11:05 juniper juniper: ppp:LCP Closing
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 12, C02 Call 
Terminated 
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 13, C01 
Outgoing Call dev=5 ch=0  
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 13, C02 OutCall 
Connected 512000  
Jun 28 13:11:05 juniper juniper: ppp:LCP Starting
Jun 28 13:11:05 juniper juniper: ppp:LCP Opening
Jun 28 13:11:05 juniper juniper: ppp:CHAP Shutdown
Jun 28 13:11:05 juniper juniper: ppp:LCP Closing
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 13, C02 Call 
Terminated 
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 14, C01 
Outgoing Call dev=5 ch=0  
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 14, C02 OutCall 
Connected 512000  
Jun 28 13:11:05 juniper juniper: ppp:LCP Starting
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 14, C02 Call 
Terminated 
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 8, C01 Outgoing 
Call dev=5 ch=0  
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 8, C02 OutCall 
Connected 512000  
Jun 28 13:11:05 juniper juniper: ppp:CHAP Shutdown
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 10, C02 Call 
Terminated 
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 12, C01 
Outgoing Call dev=5 ch=0  
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 8, C02 Call 
Terminated 
Jun 28 13:11:05 juniper juniper: ppp:LCP Closing
Jun 28 13:11:05 juniper juniper: ppp:CHAP Shutdown
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 12, C02 Call 
Terminated 
Jun 28 13:11:05 juniper juniper: ppp:CHAP Shutdown
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 8, C01 Outgoing 
Call dev=5 ch=0  
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 8, C02 Call 
Terminated 
Jun 28 13:11:05 juniper juniper: ppp:LCP Opening
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 11, C02 Call 
Terminated 
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 13, C02 Call 
Terminated 
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 9, C01 Outgoing 
Call dev=5 ch=0  
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 10, C01 
Outgoing Call dev=5 ch=0  
Jun 28 13:11:05 juniper juniper: ppp:CHAP Shutdown
Jun 28 13:11:05 juniper juniper: board 0 line 0 channel 0, call 13, C02 Call 
Terminated 
Jun 28 13:11:09 teak viagrad: link up, ISP's gateway: 193.29.223.169


I can't see anything about forcing logger to flush from its man page, so
could this be the cause?:

$ mount | fgrep log
/dev/wd0f on /var/log type ffs (local, noatime, nodev, noexec, nosuid, softdep)

-- 
Craig Skinner | http://www.kepax.co.uk | [EMAIL PROTECTED]

Reply via email to