Monitoring Tomcat and JVM via Tomcat jmxproxy

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
pof2
Posts: 4
Joined: Mon Apr 27, 2009 3:38 pm

Monitoring Tomcat and JVM via Tomcat jmxproxy

Post by pof2 »

Uses the jmxproxy that comes built in with tomcat manager to monitor Tomcat and the JVM. Lets you monitor the following:

Garbage Collectors
Time spent garbage collecting
Numer of collections

Memory Pools
Max
Used
Committed

Tomcat Thread Pools
Size
Numer of busy threads

Web Modules (contexts)
Total processing time for module.

Servlets
Requests / second
Total time
Time / Request

Any MBean
You can use the query script to get data from any MBean.


Data is collected using a perl script. Tested on Ubuntu 8.04 and cacti 0.8.7b
Attachments
GC
GC
gc.png (32.25 KiB) Viewed 33991 times
Mem Pool
Mem Pool
oldgen.png (27.24 KiB) Viewed 33991 times
Servlet
Servlet
servlet.png (30.66 KiB) Viewed 33991 times
cacti-tomcat-0.8.tar.gz
Thread Pool
(13.02 KiB) Downloaded 2731 times
threadpool.png
threadpool.png (27.14 KiB) Viewed 33991 times
substrata
Posts: 2
Joined: Wed Sep 09, 2009 3:45 pm

Post by substrata »

Thanks a lot for these scripts and templates! Having a little trouble with the perl script though, trying to set the port to 8080. It doesn't seem to recognize the change. Any ideas?
substrata
Posts: 2
Joined: Wed Sep 09, 2009 3:45 pm

Post by substrata »

I figured it out, line 313 should be changed to this:

my $url = $proto."$host:$port".$jmxurl.$qry;

However, still having some trouble. Which version of Tomcat/Java was this tested with?

Thanks!
baribal
Posts: 6
Joined: Thu Mar 25, 2010 3:48 am

Post by baribal »

Also have problems with Tomcat 6.0. Could you please tell me which Tomcat/Java version your script works with?
seb50
Posts: 1
Joined: Thu Jul 29, 2010 3:36 am

Post by seb50 »

Got this working with Tomcat 6.0 by

a) editing each xml file to have the full perl binary path in it eg

<script_path>/usr/bin/perl |path_cacti|/scripts/tomcat_stats.pl</script_
path>

b) In cacti settings | visual | maximum field length, change from 30 to 80

This is with cacti 0.8.7e
gsaray101
Cacti User
Posts: 233
Joined: Thu May 17, 2007 9:18 am

Re: Monitoring Tomcat and JVM via Tomcat jmxproxy

Post by gsaray101 »

I am not able to get the graphs working. I can access the tomcat url from the cacti server:

1. when open this url from cacti, I get results withing the browser: http://<ip address of tomcat server>:7101/manager/jmxproxy/?qry=

2:

Code: Select all

OK - Number of results: 50

Name: FetchCatalina:type=Manager,path=/,host=localhost
modelerType: org.apache.catalina.session.StandardManager
algorithm: MD5
randomFile: /dev/urandom
className: org.apache.catalina.session.StandardManager
distributable: false
entropy: org.apache.catalina.session.StandardManager@eaf40c
maxActiveSessions: -1
maxInactiveInterval: 1800
processExpiresFrequency: 6
sessionIdLength: 16
name: StandardManager
pathname: SESSIONS.ser
activeSessions: 0
sessionCounter: 1
maxActive: 10
sessionMaxAliveTime: 1859
sessionAverageAliveTime: 1823
rejectedSessions: 0
expiredSessions: 20
processingTime: 0
duplicates: 0

Name: FetchCatalina:type=RequestProcessor,worker=http-7101,name=HttpRequest3
modelerType: org.apache.coyote.RequestInfo
bytesSent: 90471
remoteAddr: 172.25.207.147
requestBytesSent: 0
contentLength: -1
bytesReceived: 0
requestProcessingTime: 25610
globalProcessor: org.apache.coyote.RequestGroupInfo@12cd8d4
maxRequestUri: /agent/admin/status
requestBytesReceived: 0
serverPort: -1
stage: 7
requestCount: 115
maxTime: 16
processingTime: 92
errorCount: 64

3. when I try to add the data query or manually execute the script against this tom cat server, I get nothing back:

D:\cacti\scripts>tomcat_stats.pl <ip address of tomcat > gc index

D:\cacti\scripts>

what am I missing, I think I am very close. please help.

thanks
DrValoo
Posts: 1
Joined: Tue Dec 28, 2010 5:27 am

Re: Monitoring Tomcat and JVM via Tomcat jmxproxy

Post by DrValoo »

Hi, I have the same probleme

"
3. when I try to add the data query or manually execute the script against this tom cat server, I get nothing back:

D:\cacti\scripts>tomcat_stats.pl <ip address of tomcat > gc index"

any feedback ?

Tomcat6
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Re: Monitoring Tomcat and JVM via Tomcat jmxproxy

Post by phalek »

Hi all,

The script needs to be changed for Tomcat 6, as the jmxurls changed:

At around line 66 replace the qry strings with the following:

Code: Select all

        if($mode eq "tp")
        {
                $qry = "*%3Atype%3DThreadPool%2C*";
        }
        elsif($mode eq "gc")
        {
                $qry = "*%3Atype%3DGarbageCollector%2C*";
        }
        elsif($mode eq "mp")
        {
                $qry = "*%3Atype%3DMemoryPool%2C*";
        }
        elsif($mode eq "wm")
        {
                $qry = "Catalina%3Aj2eeType%3DWebModule%2CJ2EEApplication%3Dnone%2CJ2EEServer%3Dnone%2C*";
        }
        elsif($mode eq "sv")
        {
                $qry = "Catalina%3Aj2eeType%3DServlet%2CJ2EEApplication%3Dnone%2CJ2EEServer%3Dnone%2C*";
        }
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
vinoo
Posts: 1
Joined: Mon Dec 06, 2010 4:58 am

Re: Monitoring Tomcat and JVM via Tomcat jmxproxy

Post by vinoo »

hi,

First very good template and good work.

The template work for:

Tomcat Servlet
Tomcat ThreadPool
Tomcat WebModule

But not for:

Tomcat GC Stats
Tomcat MemPool

My problem come from tomcat because i don't have any output from this URL:

http://host:port/manager/jmxproxy/?qry=*:type=%28GarbageCollector|MemoryPool%29,*

I don't understand why.
Is there anyone that know why?

I'm on a linux tomcat test box with:

OS: debian 5.3
Tomcat: Tomcat 5.5
JDK: 1.6.0_22-b04 and 1.5.0_22-b03 (same issue with both)

Thanks!
Khue
Posts: 45
Joined: Fri Jun 29, 2012 3:43 pm

Re: Monitoring Tomcat and JVM via Tomcat jmxproxy

Post by Khue »

Anyone actively using this with Tomcat 6? It looks immensely helpful, but I am not having much success with it. I've been messing around with Tomcat Mempool data query and verbose logging spits out the following:

Code: Select all

+ Running data query [36].
+ Found type = '4' [Script Query].
+ Found data query XML file at '/var/data/cacti/resource/script_queries/tomcat_jmxproxy_mp.xml'
+ XML file parsed ok.
+ <arg_num_indexes> missing in XML file, 'Index Count Changed' emulated by counting arg_index entries
+ Executing script for list of indexes '/var/data/cacti/scripts/tomcat_stats.pl <servername_goes_here> mp index' Index Count: 0
+ Executing script query '/var/data/cacti/scripts/tomcat_stats.pl <servername_goes_here> mp query index'
+ Executing script query '/var/data/cacti/scripts/tomcat_stats.pl <servername_goes_here> query Name'
I've updated the script as phalek recommended.
frankChina
Posts: 1
Joined: Wed Sep 12, 2012 7:52 am

Re: Monitoring Tomcat and JVM via Tomcat jmxproxy

Post by frankChina »

hi
I used this template good for monitoring Garbage Collectors ,Memory Pools ,Web Modules (contexts) ,
but when create threadpool graph,the poller always give warning like this:

09/12/2012 03:45:01 PM - POLLER: Poller[0] WARNING: Poller Output Table not Empty.
Issues Found: 6, Data Sources: currentThreadCount(DS[466]), currentThreadsBusy(DS[466]), maxThreads(DS[466]), currentThreadCount(DS[467]), currentThreadsBusy(DS[467]), maxThreads(DS[467])

with manual checking,all data were got from tomcat server, and wrote to the temp cache file.

every time the poller run, there were some records in cacti database table poller_output,

is any body can tell me why,how to deal with this problem?
thanks
stephaaan
Posts: 1
Joined: Tue Oct 02, 2012 5:01 am

Re: Monitoring Tomcat and JVM via Tomcat jmxproxy

Post by stephaaan »

Anybody knows what to put inside the index field (marked in the attached screenshot)? They're always empty if I add the source to a host :/
(and I can't add them via device > create Graphs for this host, since the graph template won't show up there...all xml files are imported, though, and I see it in the graph template section).

Thanks in advance :)
Attachments
tomcat jvm stats.png
tomcat jvm stats.png (65.27 KiB) Viewed 14769 times
ealfaroc
Posts: 1
Joined: Thu Mar 10, 2016 4:50 am

Re: Monitoring Tomcat and JVM via Tomcat jmxproxy

Post by ealfaroc »

Patch tomcat7 ThreadPool

Add following bold lines in script tomcat_stats.pl section get:

elsif($ARGV[2] eq "get")
{
my $attr = $ARGV[3];
my $index = $ARGV[4];
my $qry = $ARGV[4];

my $search = "ajp-bio-8009";
my $replace = "\"ajp-bio-8009\"";
$qry =~ s/$search/$replace/g;
$index =~ s/$search/$replace/g;

my $search = "http-bio-8080";
my $replace = "\"http-bio-8080\"";
$qry =~ s/$search/$replace/g;
$index =~ s/$search/$replace/g;

my $search = "http-bio-8443";
my $replace = "\"http-bio-8443\"";
$qry =~ s/$search/$replace/g;
$index =~ s/$search/$replace/g;


if($attr eq "" or $index eq "")
{
die("index och attribute missing");
}

my $objs = doQuery($qry);
if(not defined $objs->{$index})
{
print "$index not found\n";
}
if(not defined $objs->{$index}->{$attr})
{
print "$attr not found\n";
}
print $objs->{$index}->{$attr} ."\n";

}
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests