This program is obsolete. Replacement for netstat is ss. Replacement for netstat -r is ip route. Replacement for netstat -i is ip -s link. Replacement for netstat -g is ip maddr.
On my openSUSE Tumbleweed installation, netstat is part of the net-tools-deprecated package, which is not installed by default. So, I added support for the iproute2 set of tools.
I have no experience with awk, but I'm assuming this is a different format than netstat provides, since manually running the contents of scripts/network-bandwidth.shget_bandwidth_for_linux but replacing netstat -ie for ip -s link produces empty output.
Through some cludging around, I was able to determine that the following will process the information from iproute2 correctly. This uses jq instead of awk, since ip has the -json flag:
ip -s -json link | jq -rc '[(map(.stats64.rx.bytes) | add), (map(.stats64.tx.bytes) | add)] | .[]'
From the netstat man page:
On my openSUSE Tumbleweed installation,
netstat
is part of thenet-tools-deprecated
package, which is not installed by default. So, I added support for the iproute2 set of tools.A single run of
ip -s link
produces this output:I have no experience with awk, but I'm assuming this is a different format than netstat provides, since manually running the contents of
scripts/network-bandwidth.sh
get_bandwidth_for_linux
but replacingnetstat -ie
forip -s link
produces empty output.Through some cludging around, I was able to determine that the following will process the information from iproute2 correctly. This uses
jq
instead ofawk
, sinceip
has the-json
flag: