Sometimes, it becomes essential to monitor a non-standard port in Nagios. An example may be monitoring TCP port 5555.
Before we start, there is something that needs to be known-
- Nagios has included a bunch of custom command. The commands are defined in the directory /etc/nagios-plugins/config/
- The executable for these defined commands are located in /usr/lib/nagios/plugins/
- Checking
root@dragonfly:~# /usr/lib/nagios/plugins/check_tcp -H 192.168.10.2 -p 5555
TCP OK - 0.001 second response time on port 55|time=0.000502s;;;0.000000;10.000000
So, we can certainly conclude that port 5555 is accessible.
- Defining the command
vim /etc/nagios-plugins/config/tcp_udp.cfg
#### ADD THE CUSTOM SECTION ####
define command{
     command_name check_tcp_5555
     command_line $USER1$/check_tcp -h $HOSTADDRESS$ -p 5555 -4
}
- Defining a host to use the command
root@dragonfly:~#vim /etc/nagios3/conf.d/localhost_nagios2.cfg
define host{
        use                     linux-hosts
        host_name               bee
        alias                   bee
        address                 192.168.10.1
        }
define host{
        use                     linux-hosts
        host_name               dragonfly
        alias                   dragonfly
        address                 192.168.10.2
        }
define hostgroup{
        hostgroup_name  linux-hosts
        alias           Linux Hosts
        members         dragonfly, bee;
        }
define service{
        use                             generic-service         ; Name of service template to use
        hostgroup_name                  linux-hosts
        service_description             Check Host
        check_command                   check-host-alive
        check_command                   check_tcp_5555        ; our customized command
        }
- Restarting the service
root@dragonfly:~# /etc/init.d/nagios3 restart
Nagios should now be monitoring TCP port 5555. We can check it out by going to the Nagios page in the browser ^_^.
If it doesn't, check out the Nagios log at /var/log/nagios3/nagios.log.
Hope this helps.
 
0 comments:
Post a Comment