Using Netstat to Monitor Network Services

Monitoring your dedicated server is a good way to prevent attacks, crashes, and other problems that invariably creep up.  Although there are many external tools to help you monitor your server, Linux-powered servers also have plenty of internal tools that can help you with both monitoring and troubleshooting.

Netstat is a small network tool that can tell you exactly which processes are using a port.  Normally, netstat will show you all ports in use and all of the process using them, but you can use grep to limit those to only a specific port.  For example, if you want to know what is running on port 80, you would type:

netstat -ant | grep 80

If all goes according to plan, you should find the expected Apache child processes listed as running on port 80.  That will show you the processes on port 80, and if you wanted to count the number of port 80 connections, you could use:

netstat -an |grep :80 |wc -l

To see which ports your server is listening on, type:

netstat -ant | grep LISTEN

Netsat is a powerful command, especially when you use it in conjunction with grep.  For more information about what netstat can do, type “man netstat” from the command line or read the manual online.











Comments: