简体   繁体   中英

How to get networking stats of a linux box using /proc filesystem

I am trying to retrieve CPU, disk and networking stats using the /proc filesystem. I was able to successfully retrieve cpu and disk stats from /proc/stat and /proc/diskstats. I still haven't found the right way to collect network statistics.

The stats I would like to collect on a per linux box basis:

  • Average network throughput
  • Total number of packets received per second
  • Total number of packets transmitted per second
  • Total number of kilobytes received per second
  • Total number of kilobytes transmitted per second
  • Number of multicast packets received per second
  • Number of TCP sockets currently in use
  • Total number of sockets currently in use

I know that I can get these stats using sar but I want to write an independent program that performs similar to sar. It will be great if someone can explain from where sar retrieves this information and how it processes them to arrive at these stats on a periodic basis.

There are great network bandwidth monitoring tools which can help you getting this information almost, like slurm,bmon. You can know more from this URL :- http://www.binarytides.com/linux-commands-monitor-network/

Thanks & Regards,
Alok Thaker

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM