On Linux, how can I (programmatically) retrieve the following counters on a per-interface basis:
- Sent/received ethernet frames,
- Sent/received IPv4 packets,
- Sent/received IPv6 packets.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should be able to do this using
iptablesrules and packet counters, e.g.And to view the stats, parse the output of these:
You should also look up the
-Zflag for when you want to reset the counters.