So I have created a Linux resource monitoring tool that pulls various resource information. One of the fields I am trying to pull is the percent of network throughput on my NIC. So if I have a 1 Gb(bit) NIC with 200 Mb(bit) being processed every second, the tool would display 20%. Basic calculations are below as an example.
sar -n DEV 1 1 #Used to pull Rx and Tx KB(byte) per second.
From here lets say it reports a total of 17000 KB(bytes). I then need to convert this to Kb(bits). So I would do the following.
17000 * 8
This gives me a total of 136000 Kb(bits). I need to turn this into Mb(bits) to get a percentage from my actual NIC speed.
136000 / 1000
I divide by 1000 to change this into Mb(bits). Total is now 136 Mb. From here I need to get a percentage based on my NIC. I have a 1Gb(bit) NIC.
136 / 1000 (NIC speed in Mb) * 100
This equals 13.6%
So a rough calculation would tell me that my NIC is processing 13.6% of what it is said to be able to process by the vendor.
My questions are below. If this is the wrong site, please forward me on as this is part networking, part math, and part Linux/OS reporting so I wasn't sure what to use. Thank you
- Is my reasoning flawed? For example, is my math correct on how I retrieve my percentage
- Obviously I would never get to 100% (theoretical), but wouldn't this information be useful for spotting a potential chokepoint in the network?
- What are the Pro's and Con's of displaying this information in my tool? I have heard people say this is pointless and error prone, but I have never understood their reasoning.
sar -n DEV 1 5