Get network utilization from command line
In the Windows task manager there is a handy network tab which shows the link speed and network utilization (in percentage of available bandwidth) for connected network adapters:
Is there a way to get this information through the command line?
Solution 1:
There are a (large?) number of command line options that give information on network usage. This deals with that, and answers there have a significant overlap with the present OP. Many of them do not provide percentage bandwidth usage, as asked in the OP.
The option with Wireshark was given above.
-
typeperf
(Windows native) is also relevant, with a few options.typeperf -q "Network Interface"
lists all the objects. Then, usetypeperf "\Network Interface(*)\...
with the following options:\Network Interface(*)\Current Bandwidth \Network Interface(*)\Bytes Total/sec \Network Interface(*)\Bytes Received/sec \Network Interface(*)\Bytes Sent/sec \Network Interface(*)\Packets/sec \Network Interface(*)\Packets Received/sec \Network Interface(*)\Packets Sent/sec
Note that the formula is
((Total Bytes/Sec * 8)/current bandwidth) * 100
. Other useful options:\Network Interface(*)\Packets Received Unicast/sec \Network Interface(*)\Packets Received Non-Unicast/sec \Network Interface(*)\Packets Received Discarded \Network Interface(*)\Packets Received Errors \Network Interface(*)\Packets Received Unknown \Network Interface(*)\Packets Sent Unicast/sec \Network Interface(*)\Packets Sent Non-Unicast/sec \Network Interface(*)\Packets Outbound Discarded \Network Interface(*)\Packets Outbound Errors \Network Interface(*)\Output Queue Length \Network Interface(*)\Offloaded Connections
You can use flag
-sc <samples>
(Specifies the number of samples to collect. The default is to collect data until CTRL+C is pressed), see official documentation.
Flag-o <filename>
(Specifies the path for the output file, or the SQL database. The default is STDOUT (written to the command window).) may also be useful. An interesting script, which may be customized to give various pieces of information and format it, is given here.
Solution 2:
This can be done without installing anything through PowerShell.
You can see the Total Speed and name of each adapter using:
Get-NetAdapter
You can then take the name and put in into unique id and see the amount on incoming traffic with:
Get-Counter "\Network Interface(<unique id>)\Bytes Received/sec"
If you want outgoing or total traffic, use:
Get-Counter "\Network Interface(<unique id>)\Bytes Sent/sec"
Get-Counter "\Network Interface(<unique id>)\Bytes Total/sec"
You can also measure usage over time by adding something like:
-SampleInterval 3 -MaxSamples 5
See the help page for more info.
Solution 3:
Install Wireshark and use tshark
to collect stats:
tshark -z <statistics>
You can use netstat
:
netstat -a -n
Or typeperf
:
typeperf "Network Interface(*)\Current Bandwidth"
typeperf "Network Interface(*)\Bytes Total/sec"