0

sar -n DEV 1 1 command

gives the stats rxkB/s(Number of kilobytes read from the device per second.) and wxkB/s (Number of kilobytes written to the device per second.)

Is it possible to calculate this value from the stats found under /sys/class/net/<interface>?

user2761431
  • 101
  • 3

1 Answers1

0
  • One point to read total rx and tx : /proc/net/dev
  • Another one point to read total transferred rx: /sys/class/net/<dev_name>/statistics/rx_bytes

But as you can see it's total/ not per second. So you need do own calculations, with needed granularity get stats from proc or sys and then calculate stats per second. Get stats for now, get stats after some period than do subtraction and you get needed data.

Ivan Gurzhiy
  • 306
  • 1
  • 1