Joustie's blog

Mar 8, 2012 - 1 minute read - linux monitoring nagios nagios-plugin perl OSS

Monitoring multiple tcp-ports at once in Nagios

During the last two months I have been setting up Nagios as a side project. We have a lot of new customers coming in and we need to have a tight grip on our systems to satisfy service levels. So as I set up a Debian host to run Nagios on and was making progress in adding systems, I encountered several issues.

One of them was the fact that I need to monitor several tcp ports that are utilized in the applications we are running in a JBoss container. The default script in Nagios to monitor a tcp-port works well and I have used it to create a custom plugin to monitor several ports sequentially.

I have defined a service for this in Nagios and you can see this service is applied to a particular host group:

Below is the code I have put in /usr/lib/nagios/plugins/check_tcp_multiport.pl