LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 01-31-2012, 09:15 AM   #1
call_krushna
Member
 
Registered: Aug 2007
Location: India
Distribution: Ubuntu
Posts: 164

Rep: Reputation: 1
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 .
 
Old 01-31-2012, 05:07 PM   #2
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 12.04 / CentOS 6.5
Posts: 384

Rep: Reputation: 61
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.
 
1 members found this post helpful.
Old 02-01-2012, 02:53 AM   #3
call_krushna
Member
 
Registered: Aug 2007
Location: India
Distribution: Ubuntu
Posts: 164

Original Poster
Rep: Reputation: 1
Hi arashi256 ,

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

Thanks in advance
 
Old 02-01-2012, 03:34 AM   #4
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 12.04 / CentOS 6.5
Posts: 384

Rep: Reputation: 61
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.
 
1 members found this post helpful.
Old 02-01-2012, 03:50 AM   #5
call_krushna
Member
 
Registered: Aug 2007
Location: India
Distribution: Ubuntu
Posts: 164

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by arashi256 View Post
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 ?
 
Old 02-01-2012, 04:18 AM   #6
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 12.04 / CentOS 6.5
Posts: 384

Rep: Reputation: 61
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.
 
1 members found this post helpful.
Old 02-02-2012, 04:21 AM   #7
call_krushna
Member
 
Registered: Aug 2007
Location: India
Distribution: Ubuntu
Posts: 164

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by arashi256 View Post
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 .
 
Old 02-02-2012, 04:42 AM   #8
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 12.04 / CentOS 6.5
Posts: 384

Rep: Reputation: 61
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nagios 3.1.2 + RHEL 5.3 You don't have permission to access /nagios/ on this server psix Linux - Server 12 05-14-2011 06:26 AM
Nagios Monitor bsdfan Linux - Networking 1 07-26-2010 02:36 AM
How to monitor a Tomcat Java server in case of problems? Ujjain Linux - Server 9 08-25-2009 07:06 AM
Nagios on tomcat Vince-0 Linux - Software 2 04-22-2008 04:06 AM
How to make Tomcat 4.0.1 and Tomcat 5.0.28 coexist in one server? g18397 Linux - Software 0 05-16-2006 03:16 AM


All times are GMT -5. The time now is 12:46 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration