zhao yang
zhao yang

Reputation: 1

how to count traffic bytes with nf_conntrack

an arm device, not has iptables, have a bussiness process, need to count all traffic bytes of this process.

my solution:

  1. get socket id, ls -lh /proc/pid/fd
  2. get port by socket id, /proc/net/tcp
  3. get nf_conntrack info, cat /proc/net/nf_conntrack | grep port
  4. count bytes

if my collection frequency is 1 minute, i warry some connection info will be clear by system in 1 minute, that will reduce the accuracy of collection.

what i can do to ensure the accuracy of collection? help to give some advices, thanks a lot

Upvotes: 0

Views: 89

Answers (0)

Related Questions