nstat
nstat shows network statistics and counters.Users of the command-line are typically aware of the netstat command. The package that netstat belongs to is getting deprecated and slowly replaced with tools like ip. This is also where nstat comes in, a more modern approach to pulling in data from the kernel. Another benefit is that it can retrieve more information than netstat. This is due to the static list of metrics that netstat looks for, while nstat will parse output files from /proc.
Sources that nstat uses to retrieve its information include the following files.
- /proc/net/netstat
- /proc/net/snmp
- /proc/net/snmp6
- /proc/net/sctp/snmp
- /proc/uptime
Installation
When nstat is not installed by default, it can be added to the system using the relevant software package.
Package information for nstat
Operating system | Package name | Installation |
---|---|---|
AlmaLinux | iproute |
|
Arch Linux | iproute2 |
|
Debian | iproute2 |
|
Fedora | iproute |
|
Red Hat Enterprise Linux | iproute |
|
Rocky Linux | iproute |
|
Ubuntu | iproute2 |
|
Your Linux distribution using a different package? Share your feedback.
Usage
Available options
Short option | Long option | Description |
---|---|---|
-a | --ignore | Show absolute values instead of incremented values |
-d | --scan <INTERVAL> | Daemon mode and collect statistics with specified interval |
-j | --json | JSON output |
-h | --help | Display help |
-n | --nooutput | No output, but do update the history |
-p | --pretty | Make output easier to read. To be used with --json |
-r | --reset | Reset history, allows showing totals |
-s | --noupdate | Don't update history, include counters during next run |
-t | --interval <INTERVAL> | Disk activity summary |
-z | --zeros | Also show counters with a value of zero |
Missing an option in this overview? Share your feedback.
Relevant articles using the nstat command
The following articles include an example on how to use nstat and might be worth further exploring.