LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Need to monitor tomcat using Nagios server (https://www.linuxquestions.org/questions/linux-server-73/need-to-monitor-tomcat-using-nagios-server-926723/)

call_krushna 01-31-2012 09:15 AM

Need to monitor tomcat using Nagios server
 
Hi Team,

I have a live nagios server(EC2) which is monitoring around number of linux clients(EC2 instances) .I want to monitor tomcat for one linux client .Any help will be highly appreciable .

Note :- I can do it using check_http plugin with port no
But our development team doesn't like to monitoring it using port no.The plugin available in nagios site needs user name and password to monitor it while we have password less authentication for all the servers .

arashi256 01-31-2012 05:07 PM

Why don't you write your own plugin to either check the output of "pidof catalina" or check the access logs for the last modified date of the access log via NRPE? Nagios plugins are pretty easy to write in Perl. I've done this to monitor all sorts of processes and logs on NRPE clients. That way, you don't need to have the Tomcat instance being constantly hit with unnecessary checks from the Nagios server on non-standard ports and messing up the Tomcat logs - all traffic will just travel via the NRPE port 5666.

call_krushna 02-01-2012 02:53 AM

Hi arashi256 ,

I dont have much knowledge on scripting.Is there readymade script available which I can use for checking.

Thanks in advance

arashi256 02-01-2012 03:34 AM

Well, no. Not that I'm aware of. But it's pretty simple. Here is a skeleton Perl plugin for you.

Code:

#!/usr/bin/perl

use lib "/usr/local/nagios/libexec";
use utils qw(%ERRORS &print_revision &support &usage);

# Argument will be stored in $arg.
if (@ARGV > 0) {
        my $arg1 = @ARGV[0];
        # This gets some arguments for the plugin. Disregard this if statement if no arguments needed to be passed to plugin.
        if ($arg1 eq "") {
                print "ERROR: processing arguments\n";
                exit $ERRORS{"UNKNOWN"};
        } else {
              # Do your processing here. The plugin must return one of three states, OK, WARNING or CRITICAL.
              # It's up to you to decide how to process the results and decide on the resulting state.

              # Your processing here. Something like the bash output of "pidof catalina".
              # Based on the result, set $state to either 0, 1 or 2.

              if ($state == 0) { print "OK: Process running normally\n"; exit $ERRORS{"OK"}; }
              if ($state == 1) { print "WARNING: Process or log entry failure\n"; exit $ERRORS{"WARNING"}; }
              if ($state >= 2) { print "CRITICAL: Process and log entry failure\n"; exit $ERRORS{"CRITICAL"}; }
        }
}

Basically it's just a Perl script that can return one of three states (OK, WARNING or CRITICAL) and a string message.

call_krushna 02-01-2012 03:50 AM

Quote:

Originally Posted by arashi256 (Post 4590214)
Well, no. Not that I'm aware of. But it's pretty simple. Here is a skeleton Perl plugin for you.

Code:

#!/usr/bin/perl

use lib "/usr/local/nagios/libexec";
use utils qw(%ERRORS &print_revision &support &usage);

# Argument will be stored in $arg.
if (@ARGV > 0) {
        my $arg1 = @ARGV[0];
        # This gets some arguments for the plugin. Disregard this if statement if no arguments needed to be passed to plugin.
        if ($arg1 eq "") {
                print "ERROR: processing arguments\n";
                exit $ERRORS{"UNKNOWN"};
        } else {
              # Do your processing here. The plugin must return one of three states, OK, WARNING or CRITICAL.
              # It's up to you to decide how to process the results and decide on the resulting state.

              # Your processing here. Something like the bash output of "pidof catalina".
              # Based on the result, set $state to either 0, 1 or 2.

              if ($state == 0) { print "OK: Process running normally\n"; exit $ERRORS{"OK"}; }
              if ($state == 1) { print "WARNING: Process or log entry failure\n"; exit $ERRORS{"WARNING"}; }
              if ($state >= 2) { print "CRITICAL: Process and log entry failure\n"; exit $ERRORS{"CRITICAL"}; }
        }
}

Basically it's just a Perl script that can return one of three states (OK, WARNING or CRITICAL) and a string message.


Thanks ,
I will use this script .I will check locally.

/usr/bin/perl ./check_tomcat 127.0.0.1

Is this argument is fine ?

arashi256 02-01-2012 04:18 AM

The above code is a example framework, it won't actually do anything. As I said, you can add as many arguments as you like and process what you want as long as the end result is one of those three states. I imagine all you'd need to do is to check for the presence of the Tomcat process, so unless you want to write a generalised process watcher, I doubt you'd need any arguments to your plugin.

call_krushna 02-02-2012 04:21 AM

Quote:

Originally Posted by arashi256 (Post 4590242)
The above code is a example framework, it won't actually do anything. As I said, you can add as many arguments as you like and process what you want as long as the end result is one of those three states. I imagine all you'd need to do is to check for the presence of the Tomcat process, so unless you want to write a generalised process watcher, I doubt you'd need any arguments to your plugin.

Could you give one example .I dont know to write scripts in perl .

arashi256 02-02-2012 04:42 AM

I did above - all you need to do is set the $state variable depending on your result - $state = 0 : OK, $state = 1: WARNING, $state = 2 : CRITICAL.


All times are GMT -5. The time now is 01:28 AM.