Refreshing netstat output with Perl
NETWORK VIEW
The netstat utility reveals how your Linux box interacts with the local network. With a few Perl modules, you can develop a tool that displays the data dynamically, exactly the way top does.
When you want to know which ports are currently being used, you call netstat. This practical Linux utility can be run in several modes, which the user controls through command-line options. For example, the -s option produces network traffic statistics, and -put displays the ports of all applications that are currently communicating over TCP. Both outputs are useful, but what is really interesting is the chronological progression of events rather than a snapshot at a given moment.
The top utility serves as a model for this kind of dynamic output, displaying and continually updating the CPU load, memory usage, and other basic data of currently running processes. Thanks to CPAN, creating a dynamic terminal application like this from the static output from top is not really difficult.
Buy this article as PDF
(incl. VAT)