4

I can use the time command to measure the time some command takes:

time node -e ""
node -e ""  0.06s user 0.01s system 92% cpu 0.076 total

Is there a similar way to measure a command's network traffic (the bandwidth it used, the hosts it sent requests to, etc)? What is the best solution for this use case?

HappyFace
  • 1,612
  • 1
    Related - duplicate? https://unix.stackexchange.com/q/375387/117549 – Jeff Schaller Aug 01 '20 at 01:04
  • Read man time. Will the socket reads/writes (%r, %s) help? – waltinator Aug 01 '20 at 19:40
  • 1
    Tracking the hosts accesses would require capturing outgoing network packets. Not easy. – waltinator Aug 01 '20 at 19:43
  • @waltinator I don't see those flags on macOS's time. – HappyFace Aug 01 '20 at 19:51
  • this can be considered as a no-sense because network traffic will vary again and again doing routing doing retries & so on so measurement by "time" is just a very bad indicator ; you might prefer a traffic analysis tool or a monitor tool or trying to work around asynchronously as @waltinator said from capturing output. at worst just keep on the ping or traceroute commands – francois P Aug 02 '20 at 20:14

0 Answers0