NagiOS - Monitor Tomcat Using check_tomcat.pl Plugin - CentOS 7

nagios toturial, nagios monitoring tool, server monitoring, host & service monitor,  nagios installation, nagios core,nagios plugin , nagios configuration, nagios latest version

Step 1:

Login NagiOS Server & Install Dependency Package
yum install perl-XML-XPath perl-libwww-perl
Step 2:

Download check_tomcat.pl

A: Using WebBrowser


B: Using curl
cd /usr/local/nagios/libexec

curl "https://exchange.nagios.org/components/com_mtree/attachment.php?link_id=2522&cf_id=24" -o check_tomcat.pl
1tomcat-curl.png
chmod +x /usr/lib/nagios/plugins/check_tomcat.pl
Step 3:

Test check_tomcat.pl

cd /usr/local/nagios/libexec

./check_tomcat.pl -h
check_tomcat-help.png

./check_tomcat.pl -I 172.17.20.103 -p 8080 -l admin -a admin -w 20%,30% -c 10%,20%
check_tomcat-test.png

Step 4:

Add Command for Check Tomcat
vi /etc/nagios/objects/commands.cfg

#Check tomcat service

define command{
command_name    check_tomcat
command_line   /bin/sh -c  “$USER1$/check_tomcat.pl -H $HOSTADDRESS$ -p $ARG1$ -l $ARG2$ -a $ARG3$ -w $ARG4$ -c $ARG5$”
}

check_tomcat-command.png

Note: we can use the command_line variable as below. But sometimes you will get an error. So we can use “/bin/sh -c ” to avoid the error

Step 5:

Add Service in Client.cfg

 define service{
use                           generic-service         ; Inherit default values from a template
host_name               test-red1
service_description  Tomcat
check_command      check_tomcat!8080!admin!admin!10%,50%!5%,10%

}
check_tomcat-service.png

Step 6:

check Nagios configurations and restart
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors:   0

Things look okay – No serious problems were detected
systemctl restart nagios
Step 7:

check Nagios service monitoring page for tomcat status in Browser

         http://172.17.20.100/nagios/

tomcat-web-service.png

4 comments

Finc said...

Hello! i have an problem whit nagios, when i try to check the tomcat status, i have this error:
(Return code of 127 is out of bounds - plugin may be missing : (No output on stdout) stderr: -H: “/usr/local/nagios/libexec/check_tomcat.pl: No such file or directory))

Unknown said...

I Ve problem
Tomcat
CRITICAL 03-24-2018 03:00:41 0d 15h 14m 6s 3/3 (Return code of 127 is out of bounds - plugin may be missing : (No output on stdout) stderr: -H: “/usr/local/nagios/libexec/check_tomcat.pl: No such file or directory))


please help me to resolve as soon as possible

Unknown said...

Warning: Return code of 127 for check of service 'Tomcat' on host '#### Server' was out of bounds. Make sure the plugin you're trying to run actually exists.

Giridhar said...

Use this
define command{
command_name check_tomcat
command_line /bin/perl $USER1$/check_tomcat.pl -H $HOSTADDRESS$ -p $ARG1$ -l $ARG2$ -a $ARG3$ -w $ARG4$ -c $ARG5$
}

Powered by Blogger.