Login NagiOS Server & Install Dependency Package
yum install perl-XML-XPath perl-libwww-perl
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
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.pl -I 172.17.20.103 -p 8080 -l admin -a admin -w 20%,30% -c 10%,20%
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$”
}
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%
}
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/
Leave a Comment