How do I clear the interface stats on Linux
So one of my clients configured one of their switches and the resulting configuration resulted in a duplex mismatch between the switch and a Linux host.
We have fixed the duplex mismatch, but is there an easy way to clear the error counters on the interface without restarting the system?
eth0 Link encap:Ethernet HWaddr 00:nn:nn:nn:nn:nn
inet addr:192.168.97.166 Bcast:192.168.97.167 Mask:255.255.255.252
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:630331763 errors:1 dropped:0 overruns:0 frame:0
TX packets:676081436 errors:1971815 dropped:0 overruns:68637 carrier:1903180
collisions:7649984 txqueuelen:1000
RX bytes:2067682611 (1.9 GiB) TX bytes:1942809411 (1.8 GiB)
this is not intended, or think to be done. You may unload and load again the network driver if it's loaded as a module:
ifconfig ethX down; rmmod ethX; insmod ethX; ifconfig ethX
There will be a network outage anyway, and a risk if you can't get your hand back on it.
You may reset the switch port stats and check for new errors. Or save this current number and compare against them instead of zero
Have you seen this article?
http://www.ducea.com/2006/09/08/resetting-ifconfig-counters/
It suggests that unloading the network driver module and loading it back will reset the counters, and that if you have the module statically linked in the kernel, there's no other way than to reboot it.
The article offers justification.
Resize the ring buffers and the statistics will get reset without downtime.
ethtool -G eth1 rx 511
ethtool -G eth1 rx 4096
(RHEL 6.5)