Monitoring....
Robert G. Brown
rgb at phy.duke.edu
Sat Mar 8 15:38:56 PST 2003
On Sat, 8 Mar 2003, Donald Becker wrote:
> On Thu, 6 Mar 2003 john152 at libero.it wrote:
>
> > I'd like to do a code that monitors the link status (link active and
> > connected to net or not...) and gives me an error if this status
> > changes. Is there any software today that does so?
>
> You can easily write a script that monitors the exit status of
> mii-diag --status eth0
> or the output of
> mii-diag --watch eth0
>
> http://www.scyld.com/diag/index.html
There is one other trick that mii-diag makes possible that is so lovely
that I've seriously considered posting it back to e.g. RH for permanent
inclusion in their boot cycle. See the following modified
/etc/sysconfig/ifcfg-eth0 (or really, ethX as the same trick can be used
for each eth device). Pretty crude, but adequate.
I use a laptop that I move around a lot, booting it with/without
ethernet wire attached, with/without a wireless card. Waiting for all
its ethernet initialization to time out is a real PITA. So I used
mii-diag to check for link beat. If there is none, chance are you're
not plugged in (yet) so I set ONBOOT=no instead of yes. I can still
bring up a network manually at any time (after plugging in the wire or
whatever) but I don't have to wait.
rgb
--
Robert G. Brown http://www.phy.duke.edu/~rgb/
Duke University Dept. of Physics, Box 90305
Durham, N.C. 27708-0305
Phone: 1-919-660-2567 Fax: 919-660-2525 email:rgb at phy.duke.edu
# We are rather tired of having to wait for the interface to time out
# on boots when the system isn't on a network. We therefore check for
# the existence of a link BEFORE trying to initialize it, much as we
# check for the insertion of a PCMCIA card for the wireless interface
# on eth1.
#
# If variable NE is not empty after this call, there is no link
#
if [ -x /sbin/mii-diag ]
then
NE=`/sbin/mii-diag eth0 | grep "not established"`
fi
# So if it IS empty, we have a link and start up the interface, trusting
# that there is a dhcp server out there somewhere.
if [ -z "$NE" ]
then
# This cleans up the device and sets it so it DOES initialize
# at boot.
echo "Link beat found on interface eth0, initializing..."
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
else
# This cleans up the device and sets it so it does NOT initialize
# at boot.
echo "Warning: No link beat found, NOT initializing interface eth0!"
echo " Solution: First connect to a network, then bring up network
interface
."
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=no
fi
More information about the Beowulf
mailing list