Page 1 of 1

Linux Process Monitoring - Tomcat

Posted: Thu Apr 07, 2011 11:55 am
by SavaSC
I'm monitoring services on SLES 10 SP3. I can monitor ntpd and cron without issue, but when I monitor tomcat NagiosXI reports Nok. I can check processes, memory, and many other functions on any one of my SLES hosts, but this tomcat check fails wherever I apply it.

If I run check services here are the returns:
ltc061l:/usr/local/nagios/libexec # ./check_services -p tomcat
tomcat: 1
ltc061l:/usr/local/nagios/libexec # ./check_services -p tomcat5
tomcat: 1

Here's my own check:
ltc061l:/usr/local/nagios/libexec # service tomcat5 status
Checking for Tomcat (/srv/www/tomcat5/base/) running

Here's what XI is reporting:
tomcat
Critical 7s 1/5 2011-04-07 11:12:51 *** tomcat: Nok ***
ntpd
Ok 12m 48s 1/5 2011-04-07 11:13:33 ntpd: 1

Here's what it's using to check(ntpd is identical):
check_nrpe
$USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ $ARG2$
$ARG1$ = check_services
$ARG2$ = -a 'tomcat'

Any ideas why the check runs fine on the server but reports the service down to the console?

Re: Linux Process Monitoring - Tomcat

Posted: Thu Apr 07, 2011 12:18 pm
by tonyyarusso
Permissions. Tomcat is not allowing nagios to read its PID file most likely. Set up your check_services to use and be allowed by sudo for the nagios user.

Re: Linux Process Monitoring - Tomcat

Posted: Thu Apr 07, 2011 1:14 pm
by SavaSC
ssh as root

ltc061l:/tmp/linux-nrpe-agent # su nagios
nagios@ltc061l:/tmp/linux-nrpe-agent> cd /usr/local/nagios/libexec/
nagios@ltc061l:/usr/local/nagios/libexec> ./check_services -p tomcat
tomcat: 1
nagios@ltc061l:/usr/local/nagios/libexec>

Same result as root. Not to mention I can check other services such as cron and ntp.

Re: Linux Process Monitoring - Tomcat

Posted: Thu Apr 07, 2011 1:58 pm
by SavaSC
What's really interesting is that sometimes it checks out ok.

tomcat
Ok 2m 20s 1/5 2011-04-07 13:54:17 tomcat: 1

But the next time it checks it will fail. Or if I perform a manual check it will fail.

tomcat
Critical 6s 1/5 2011-04-07 13:58:03 *** tomcat: Nok ***

Re: Linux Process Monitoring - Tomcat

Posted: Thu Apr 07, 2011 2:19 pm
by tonyyarusso
So, I just installed Tomcat and set up that check on a CentOS 5 system, and it's working fine, so I'm afraid I have no idea what your issue might be.

Re: Linux Process Monitoring - Tomcat

Posted: Fri Apr 08, 2011 9:54 am
by SavaSC
OK, we run SLES. Any luck testing on SLES or are you saying SLES isn't supported? It's the 2nd or 3rd largest distro of Linux.

Re: Linux Process Monitoring - Tomcat

Posted: Tue Apr 12, 2011 4:47 pm
by tonyyarusso
Well, it's not supported in the sense that we aren't particularly familiar with it and don't really do testing on it normally, but I'll still take a run at it tomorrow and see if I can figure anything out for you.

Re: Linux Process Monitoring - Tomcat

Posted: Wed Apr 13, 2011 3:35 pm
by tonyyarusso
All right, it's not just you! Turns out SLES has different behavior for 'ps' than other distros, specifically when output is not directed to a tty. Edit the plugin on the SLES server, and change this line:

Code: Select all

                amt=$(ps aax | egrep "$patern" | grep -v egrep | grep -v "$PROGNAME" | wc -l | sed 's| ||g')
to this:

Code: Select all

                amt=$(ps aaxww | egrep "$patern" | grep -v egrep | grep -v "$PROGNAME" | wc -l | sed 's| ||g')
(The difference is adding 'ww' to the ps arguments.)

Re: Linux Process Monitoring - Tomcat

Posted: Mon May 16, 2011 11:54 am
by SavaSC
That worked great Tony. Thanks for checking it out!

Re: Linux Process Monitoring - Tomcat

Posted: Tue May 17, 2011 9:24 am
by tonyyarusso
Glad to hear it! Let us know if you have any further issues.