2

I want to monitor the average network usage for my Debian server.

Ive tried to mess with dstat, ntop and couple other programs but nothing seems to work like I want to.

Basically I want a program/script that outputs an average network stats each X time. Whats the best way to do what I need ?

Greetings,

0

You could take a look at netstat command. Its a simple way to get network status and statistics. A guide on how to use it: http://www.tldp.org/LDP/nag2/x-087-2-iface.netstat.html

You're probably looking for netstat -i, which will output long-term average networking statistics for all configured interfaces, plus error counters and other useful things.

Alternatively (and a bit less simply), Sar can output a huge range of data and is great for a local measure of "What is happening to X for duration Y".

This is a fair guide on how to use it: http://www.thegeekstuff.com/2011/03/sar-examples

You're looking for section (9) which reads:

  1. Report network statistics (sar -n)

This reports various network statistics. For example: number of packets received (transmitted) through the network card, statistics of packet failure etc.,. “1 3” reports for every 1 seconds a total of 3 times.

sar -n KEYWORD
KEYWORD can be one of the following:

DEV – Displays network devices vital statistics for eth0, eth1, etc.,
EDEV – Display network device failure statistics
NFS – Displays NFS client activities
NFSD – Displays NFS server activities
SOCK – Displays sockets in use for IPv4
IP – Displays IPv4 network traffic
EIP – Displays IPv4 network errors
ICMP – Displays ICMPv4 network traffic
EICMP – Displays ICMPv4 network errors
TCP – Displays TCPv4 network traffic
ETCP – Displays TCPv4 network errors
UDP – Displays UDPv4 network traffic
SOCK6, IP6, EIP6, ICMP6, UDP6 are for IPv6
ALL – This displays all of the above information. The output will be very long.

Thus, # sar -n DEV 1 2 will report on network devices one every second two times. If you wanted a fair average in a given time frame, you could specify a large "duration" value.

  • Thanks for your answer. For some reason sar network monitor is not working for me. Ive fixed couple issues but it still not work. Ive managed to run "dstat -n --bits 600 >> /log/network" and its exactly what I needed, outputs average network load every 10 minutes. But now I have next issue, I dont know how to assign proper date to every line. – Erexo Oct 9 '16 at 11:13
  • okay Ive done it. dstat -tn 600 > /root/dstat & – Erexo Oct 9 '16 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.