In addition to analyzing active network connections, the netstat
command can also be used to monitor network traffic, bandwidth utilization, and overall system performance.
Monitoring Network Traffic
To view the network traffic statistics for your system's network interfaces, you can use the following command:
netstat -i
This will display a table with information about each network interface, including the interface name, the number of packets received and transmitted, the number of errors, and the number of dropped packets.
You can also use the netstat -s
command to display detailed statistics for each network protocol, such as the number of TCP segments sent and received, the number of UDP datagrams sent and received, and the number of ICMP messages sent and received.
Monitoring Bandwidth Utilization
To monitor the bandwidth utilization of your network interfaces, you can use the netstat
command in combination with the awk
or sed
commands to extract the relevant information. For example:
netstat -i | awk '{print $1, $2, $3}'
This command will display the interface name, the number of packets received, and the number of packets transmitted for each network interface.
You can further analyze the bandwidth utilization by calculating the data transfer rate for each interface. For instance, the following command will display the interface name, the received data rate, and the transmitted data rate in kilobytes per second:
netstat -i | awk '/^[a-z]/ {printf("%10s %10.2f %10.2f\n", $1, $2/1024, $3/1024)}'
The netstat
command can also provide insights into your system's overall performance by monitoring various network-related metrics. For example, you can use the netstat -s
command to display detailed statistics on network protocol usage, such as the number of TCP retransmissions, the number of UDP datagrams dropped, and the number of ICMP messages sent and received.
By analyzing this information, you can identify potential performance bottlenecks, network congestion, or other issues that may be affecting your system's overall performance.
Remember, the netstat
command is a powerful tool, and by combining it with other Linux utilities, you can create custom scripts and dashboards to monitor and analyze your network's health and performance in real-time.