On Tue, 14 May 2002, Peter HOLZLEITNER wrote: > If I understand the original question right, the objective is to see > whether the local network card has a live connection to the network. > > Why the indirect test? Check the link status of the card itself! > > Query the local SNMP agent and check that ifOperStatus = 1. > A sample configuration for this is provided in my snmpvar.monitor. > > This mechanism is generic across hosts, switches, routers, firewalls and > what-have-you.
except for linux and ucd-snmp, at least. there isn't a standard api for getting transciever status from all ethernet interface types in linux. some cards don't even report the link status. because of this, the ucd-snmp snmpd doesn't properly report the link status for ethernet interfaces via ifOperStatus. it will, however, report "down" if you down the interface via "ifconfig eth0 down", but that's what ifAdminStatus is supposed to be for. donald becker wrote a tool called "mii-diag.c" which will fetch and report the mii status word from your ethernet interfaces, assuming they support such functionality. read more here: http://www.scyld.com/expert/mii-status.html here's an example of "mii-diag -w": Using the default interface 'eth0'. Basic registers of MII PHY #1: 3000 782d 02a8 0154 05e1 45e1 0001 0000. The autonegotiated capability is 01e0. The autonegotiated media type is 100baseTx-FD. Basic mode control register 0x3000: Auto-negotiation enabled. You have link beat, and everything is working OK. Your link partner advertised 45e1: Flow-control 100baseTx-FD 100baseTx 10baseT-FD 10baseT, w/ 802.3X flow control. End of basic transceiver information. Monitoring the MII transceiver status. 10:30:37.978 Baseline value of MII BMSR (basic mode status register) is 782d. (i then unplug the cable) 10:31:26.153 MII BMSR now 7809: no link, NWay busy, No Jabber (0000). 10:31:27.863 MII BMSR now 7829: no link, NWay done, No Jabber (45e1). (and i plug it back in) New link partner capability is 45e1 0003: 10/100 switch w/ flow control. 10:31:27.873 MII BMSR now 782d: Good link, NWay done, No Jabber (45e1). the mode status register is what you want to be looking at. with the cable plugged in (on my 82557 eepro100): ./mii-diag -v eth0 | grep "mode status register" Basic mode status register 0x782d ... 782d. with the cable unplugged: ./mii-diag -v eth0 | grep "mode status register" Basic mode status register 0x7809 ... 7809. now, for other interfaces (such as ppp), the ucd snmp agent might properly report ifOperStatus, but i'm not sure because i never tested it. Jim Trocki <[EMAIL PROTECTED]> Computer System and Network Engineer Transmeta Corporation Santa Clara, CA
