Operating System - Linux
1752790 Members
5748 Online
108789 Solutions
New Discussion юеВ

Re: How to reset network interface statistics/counters?

 
Ross Minkov
Esteemed Contributor

How to reset network interface statistics/counters?


Hi Linux Gurus,

How can I reset the interface statistics (or interface counters) for a Linux network interface without bringing the system down or editing /proc/net/dev directly? I used to support Tru64 UNIX and the netstat command had -z switch to zero (reset) the interface counters and the -I switch to specify the interface. I don't see this in the Linux netstat command.

Thanks,
Ross
11 REPLIES 11
Rick Garland
Honored Contributor

Re: How to reset network interface statistics/counters?

Check the 'mii-tool' or the 'ethtool' commands.

Ross Minkov
Esteemed Contributor

Re: How to reset network interface statistics/counters?

Rick,

I did check both of these and did not see any switches to solve my problem... but then maybe I missed it. Do you know what the switch is to reset the interface counters?

Thanks,
Ross
Stuart Browne
Honored Contributor

Re: How to reset network interface statistics/counters?

In all honesty, I'm unaware of a way to do this.

But please, why do you want to do it? I'm having trouble trying to understand why you'd want to reset the interface counters.

In any case, if you do need some sort of re-settable counter, use IPTables based on an interface.
One long-haired git at your service...
Gopi Sekar
Honored Contributor

Re: How to reset network interface statistics/counters?


Hi,

According to Linux network developers, the network counters are not supposed to be reset. If you really want to this you hack the kernel code to this.

A simple but not so straight forward method is to stop the network interface remove the driver and reload the driver back, this will reset counter values to 0.

Hope this helps,
Gopi
Never Never Never Giveup
Ross Minkov
Esteemed Contributor

Re: How to reset network interface statistics/counters?

Thanks Gopi.

> According to Linux network developers, the network counters are not supposed to be reset.

Can you point me to some documentation that states that, please?

Thanks,
Ross
Gopi Sekar
Honored Contributor

Re: How to reset network interface statistics/counters?

The following link is a message thread which states that.

http://nylug.org/pipermail/nylug-talk/2005-February/025665.html

you can also accomplish the task by a simple shell program.

if it is for RH then you can get network driver name from /etc/modprobe.conf

Hope this helps,
Gopi
Never Never Never Giveup
Sergejs Svitnevs
Honored Contributor

Re: How to reset network interface statistics/counters?

There is no way to reset this bytes without restarting. The data is located at /proc/net/dev so it is not writeable. You clear the counters by unloading and reloading
a network driver module (ifconfig ethX down; rmmod ethX;insmod ethX;ifconfig ethX).

Regards,
Sergejs

rick jones
Honored Contributor

Re: How to reset network interface statistics/counters?

Since the counters cannot be reset (just what would a remote monitor do if that happened?) you might try the beforeafter tool to get stats for an interval - take a snapshot "before" and one "after" and run them through beforeafter to get the "delta"

ftp.cup.hp.com/dist/networking/tools/ - you will need to compile the .c file for linux - it is an hp-ux pa-risc binary at the moment. might be good to do a bit of sanity checking on the output as it doesn't have tooooo much linux exposure.
there is no rest for the wicked yet the virtuous have no pillows
david moscrip
New Member

Re: How to reset network interface statistics/counters?

in linux there is a tool called iptraf that
can do stats of many types of network info,
per protocol, per interface, per etc. . . .
om debian you just as root type "apt-get install iptraf" in a terminal window. In others, you resort to other methods, or get the source. here is a link from freshmeat:
http://freshmeat.net/projects/iptraf/
cassanova is just being punished for going to desolation row