Click to See Complete Forum and Search --> : interface counters


STORMPROOF
12-19-2005, 01:04 PM
How do you clear the interface stats such as eth0 in linux?

In the cisco world it is easy. "clear counters"

STORMPROOF
01-05-2006, 05:49 PM
No body knows the answer to this.

serz
01-05-2006, 07:08 PM
I always wondered how to do this, too.

knute
01-05-2006, 07:42 PM
Forgive my ignorance here, but what stats are you talking about, that are recorded where, and how are they accessed?

serz
01-05-2006, 07:49 PM
eth0 Link encap:Ethernet HWaddr 00:06:7B:00:10:77
inet addr:***.***.**.*** Bcast:255.255.255.255 Mask:255.255.255.0
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:37983265 errors:0 dropped:0 overruns:0 frame:0
TX packets:9305906 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3189232018 (3041.4 Mb) TX bytes:3887987751 (3707.8 Mb)
Interrupt:11 Base address:0x6300

I think that he reffers to those.

knute
01-05-2006, 09:13 PM
Ahhh...try this command:
cat /proc/net/dev

serz
01-05-2006, 09:43 PM
What he wants to do is reset all those counters.. basically what's been transmitted/received.

STORMPROOF
01-06-2006, 01:06 AM
What he wants to do is reset all those counters.. basically what's been transmitted/received.

Serz you are exactly right, that is what I am after.

Icarus
01-06-2006, 02:49 AM
ifconfig eth0 down
ifconfig eth0 up

other then restarting the interface, I don't know either

serz
01-06-2006, 11:48 PM
No Icarus, I've tried that in the past and it didn't work :(

knute
01-07-2006, 12:23 AM
I don't know how to change it in ifconfig, but I did run across a sweet article using iptables to track stats.

http://enterprise.linux.com/enterprise/05/12/15/177232.shtml?tid=129&tid=100

HTH

voidinit
01-08-2006, 03:54 AM
As far as I know, those statistics are calculated and kept by the interface driver. If you have the driver compiled in as a module, you can always rmmod/insmod the module and they *should* reset. If the driver is statically compiled and you are feeling particularly industrious you could implement a rollover or a hook for a user space "resetter" program in the module code.




root@olympus:/# ifconfig
eth0 Link encap:Ethernet HWaddr 00:80:AD:0C:E5:BF
inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:31727 errors:0 dropped:0 overruns:0 frame:0
TX packets:64621 errors:1 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2096650 (1.9 Mb) TX bytes:97667507 (93.1 Mb)
Interrupt:11 Base address:0xec00

root@olympus:/# modprobe -r dmfe; modprobe dmfe; /etc/rc.d/rc.inet1; ifconfig eth0

eth0 Link encap:Ethernet HWaddr 00:80:AD:0C:E5:BF
inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11 Base address:0xec00

serz
01-08-2006, 10:11 PM
Oh, cool.. that'd work as long as you use a module for your NIC.

STORMPROOF
01-12-2006, 12:12 AM
Thanks that looks like it should work. Most of the time aren't the drivers compiled as a module??






As far as I know, those statistics are calculated and kept by the interface driver. If you have the driver compiled in as a module, you can always rmmod/insmod the module and they *should* reset. If the driver is statically compiled and you are feeling particularly industrious you could implement a rollover or a hook for a user space "resetter" program in the module code.




root@olympus:/# ifconfig
eth0 Link encap:Ethernet HWaddr 00:80:AD:0C:E5:BF
inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:31727 errors:0 dropped:0 overruns:0 frame:0
TX packets:64621 errors:1 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2096650 (1.9 Mb) TX bytes:97667507 (93.1 Mb)
Interrupt:11 Base address:0xec00

root@olympus:/# modprobe -r dmfe; modprobe dmfe; /etc/rc.d/rc.inet1; ifconfig eth0

eth0 Link encap:Ethernet HWaddr 00:80:AD:0C:E5:BF
inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11 Base address:0xec00

voidinit
01-12-2006, 02:36 AM
Thanks that looks like it should work. Most of the time aren't the drivers compiled as a module??

In most "out of the box" configurations yes, they are compiled as a module. I wouldn't count on it being a constant or even a near constant though.

serz
01-12-2006, 09:45 AM
Yeah, it depends. When I compile the kernel by myself, I don't use modules.