> I believe you can get this info if you add the net/snmp or net/snmp4 > port.
Hi Larry, Thanks for replying. Hmmm. I'm talking about code that uses a FreeBSD-specific sysctl to interrogate the in-kernel if MIB counters, like this: /* gather stats */ int freebsd_sysctl_get(struct Devices*dev, unsigned long* ip, unsigned long* op, unsigned long* ib, unsigned long* ob) { struct ifmibdata* drvdata = dev->drvdata; int datamib[6]; int len; *ip = *op = *ib = *ob = 0; datamib[0] = CTL_NET; datamib[1] = PF_LINK; datamib[2] = NETLINK_GENERIC; datamib[3] = IFMIB_IFDATA; datamib[4] = 1; /* fill in later */ datamib[5] = IFDATA_GENERAL; datamib[4] = IFMIB_IFCOUNT; len = sizeof(struct ifmibdata); if(sysctl(datamib, 6, drvdata, &len, NULL, 0) < 0) return 1; *ip = drvdata->ifmd_data.ifi_ipackets; *op = drvdata->ifmd_data.ifi_opackets; *ib = drvdata->ifmd_data.ifi_ibytes; *ob = drvdata->ifmd_data.ifi_obytes; return 0; } But these stats don't seem to be collected for at least some network card drivers, presumably because those drivers aren't collecting those stats, e.g. they don't #include <net/if_mib.h>, and thus don't allocate a mib structure or increment any counters in that structure. I can confirm that it definately doesn't work for the 'wi' and 'lo' drivers... However, it definately seems to work for the xl driver... Try this: cd /usr/src/sys/dev; find . -exec grep mib {} /dev/null \; 'awi', 'ed' & 'ray' drivers seem to have the most complete implementations, but 'fe' & 'xe' seem to have partial implementations (error counters only). They're relatively short, so here's one by way of illustration: ./xe/if_xe.c:#include <net/if_mib.h> ./xe/if_xe.c: scp->ifp->if_linkmib = &scp->mibdata; ./xe/if_xe.c: scp->ifp->if_linkmiblen = sizeof scp->mibdata; ./xe/if_xe.c: scp->mibdata.dot3StatsSingleCollisionFrames++; ./xe/if_xe.c: scp->mibdata.dot3StatsCollFrequencies[0]++; ./xe/if_xe.c: scp->mibdata.dot3StatsMultipleCollisionFrames++; ./xe/if_xe.c: scp->mibdata.dot3StatsCollFrequencies[scp-> tx_collisions-1]++; ./xe/if_xe.c: scp->mibdata.dot3StatsMultipleCollisionFrames += sent; ./xe/if_xe.c: scp->mibdata.dot3StatsExcessiveCollisions++; ./xe/if_xe.c: scp->mibdata.dot3StatsMultipleCollisionFrames++; ./xe/if_xe.c: scp->mibdata.dot3StatsCollFrequencies[15]++; ./xe/if_xe.c: scp->mibData.dot3StatsMissedFrames++; ./xe/if_xe.c: scp->mibdata.dot3StatsFrameTooLongs++; ./xe/if_xe.c: scp->mibdata.dot3StatsFCSErrors++; ./xe/if_xe.c: scp->mibdata.dot3StatsAlignmentErrors++; ./xe/if_xe.c: scp->mibdata.dot3StatsInternalMacReceiveErrors++; ./xe/if_xevar.h: struct ifmib_iso_8802_3 mibdata; However, most of the drivers don't seem to have any code like this in them - and at least some of those drivers don't work with the 3rd-party application code above. Should they? Or is this an older interface? I'd like to advise the author so he can fix a very useful dockapp for me - or, if this is the way to go, I'll badger Bill Paul to fix the 'wi' driver - oh, wait a moment, maybe generating patches would be safer :) Regards, AS
msg34908/pgp00000.pgp
Description: PGP signature