Subject: ifwatcher written! [was Re: Getting laptop to auto-dhclient]
To: Steven M. Bellovin <smb@research.att.com>
From: Brian Grayson (home) <bgrayson@austin.rr.com>
List: netbsd-users
Date: 10/12/2003 00:07:24
On Sat, Oct 11, 2003 at 04:45:21PM -0500, Brian Grayson (home) wrote:
> 
>   For now, I may do something like take ifconfig and hack it to just
> check status every few seconds, and when it detects a delta, have it
> fire off some script to DTRT.

  I hacked, and now have a program (tentatively called ifwatcher)
that checks the status of the named interface, and when it changes,
runs /etc/ifwatch <interface> <active|inactive>.

  I did a little bit of optimization, and it can run 50 times a second
without making much of a blip in the load of the machine (10 CPU
seconds after 4 minutes).  So running it at 1-second intervals
would put it in the noise.  Not worth any further optimization effort,
IMO.  And it should be _significantly_ faster than running "ifconfig
tlp0 | grep status...."

  I'll try it on my laptop at work on Monday.  I've placed a Makefile
and ifwatcher.c at ftp.netbsd.org/pub/incoming/bgrayson/ifwatcher/v0.1.
It's one big hack, so caveat ftp'er.

  Ah, the power of the source!

  Brian