Another JVM Monitoring template

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

Moderators: Developers, Moderators

ianand0204
Posts: 2
Joined: Mon Sep 18, 2006 1:45 pm

Another JVM Monitoring template

Post by ianand0204 »

This is my first template that I have created for cacti, so I would appreciate any feedback.

I thought I would append my template here for monitoring JVM stats. The values which are exported from the JVM correspond to the java.lang.management MXBean.
http://java.sun.com/j2se/1.5.0/docs/api ... mmary.html

You still need to follow the instructions on sun's website for enabling SNMP polling on a JVM which are located at the link below.
http://java.sun.com/j2se/1.5.0/docs/gui ... /SNMP.html

In my case I created separate devices for my JVM's and then poll on a port other than 161. This allows me to poll snmpd as well as the jvm.

i.e.
snmpd listens on port 161
jvm snmp listens on port 163

When configuring the jvm device, change the snmp port to 163.

This template graph's the following values for the Memory Pools listed below:

PS - Code Cache
PS - Eden Space
PS - Old Gen
PS - Perm Gen
PS - Survivor Spa

The values which are graphed are:

Memory Pool Max Size
Memory Pool Initial Size
Memory Pool Used
Memory Pool Committed
Peak Max Memory Pool
Peak User Memory Pool
Peak Comited Memory Pool
Collected Max Memory Pool
Collected Used Memory Pool
Collected Committed Memory

The template is fairly generic so hopefully it will work for everyone.


*NOTE* The screen shot is a little misleading. All values listed in the index are graphed, it just so happens that this screen shot was taken off an idle machine and thus doesn't display much difference in data.

This template was exported from cacti 0.8.6j so you will probably need the same version.[/url]
Attachments
cacti_graph_template_jvm_jvmmempooltable.xml.txt
(39.07 KiB) Downloaded 2059 times
jvm_mem.xml.txt
(3.72 KiB) Downloaded 2634 times
Screenshot-cacti - Mozilla Firefox.png
Screenshot-cacti - Mozilla Firefox.png (56.49 KiB) Viewed 44022 times
elayaraja.s
Cacti User
Posts: 137
Joined: Mon Feb 11, 2008 3:46 am

Scritp file ?

Post by elayaraja.s »

If any script file used for the above requirement to monitor JVM, please upload the script file and also ensure

1) the above attached xml file cacti_graph_template_jvm_jvmmempooltable.xml.txt is xml file which we need to import in cacti ?
2) why we require this file jvm_mem.xml.txt , is it Dataquery required to place in '<cacti_path>\resource\snmp_queries' ?
amacks
Posts: 12
Joined: Thu May 22, 2008 10:23 pm

Work?

Post by amacks »

Has anyone gotten this template to work sucessfully? It imports for me, but complains that there is one missing data source. I feel like there is something small I'm missing
thanks
Aaron
will chung
Posts: 8
Joined: Mon Oct 09, 2006 2:48 pm

Post by will chung »

I got it to work, but it doesn't seem to graph anything correctly (atleast for me). I *always* got the same #'s for everything, and they never incremented so I knew something wasn't right. Plus when I checked on the host itself, the results I got back didn't correlate to what I was graphing.

So... I actually ended up making my own data templates and created my own graphs.

The OIDs are described here:

http://support.ipmonitor.com/mibs/JVM-M ... /oids.aspx

I'm graphing permgen init size:
1.3.6.1.4.1.42.2.145.3.163.1.1.2.110.1.10.5

max:
.1.3.6.1.4.1.42.2.145.3.163.1.1.2.110.1.13.5

and used:
.1.3.6.1.4.1.42.2.145.3.163.1.1.2.110.1.12.5

I've verified the results back from doing a jstat -gcpermgencapacity <java pid> on the host itself and everything is Kosher. Hope this helps.
mgupta
Posts: 16
Joined: Thu Aug 13, 2009 4:29 pm
Location: Canada

Yet another JVM Graph Templates

Post by mgupta »

Here are my JVM templates.

Instructions - http://java.sun.com/javase/6/docs/techn ... /snmp.html

1. Configure SNMP on JVM

# cat snmp.acl
acl ={
{
communities = public
access = read-only
managers = localhost
}
}

# pwd
/usr/java/jdk1.6.0_16/jre/lib/management

# ls -lrth snmp.acl
-r-------- 1 root root 83 Dec 2 09:15 snmp.acl

2. Enable SNMP on JVM - Add the following argument when starting JVM
-Dcom.sun.management.snmp.port=9998

3. Put the following in your snmpd.conf (This enables you to poll remotely from ANY host, without specifying the port. See the snmpwalk below.)
proxy -v 2c -c public localhost:9998 .1.3.6.1.4.1.42

4. Restart SNMPd

5. Try - snmpwalk -v 2c -c public localhost .1.3.6.1.4.1.42

That should give you a listing. If not try netstat -an | grep 9998 to make sure that JVM is actually listening.


PS. In the JVM Mib, some counters dont really behave like counters with respect to Cacti.

If you look in my templates, almost everything is a Gauge.

Screenshots at - http://forums.cacti.net/viewtopic.php?p=178822#178822
Attachments
jvm_classes.png
jvm_classes.png (22.23 KiB) Viewed 36207 times
cacti_graph_template_jvm_-_memory.xml
(20.06 KiB) Downloaded 1370 times
cacti_graph_template_jvm_-_num_of_classes.xml
(17.5 KiB) Downloaded 1311 times
cacti_graph_template_jvm_-_opf.xml
Objects pending finalization.
(12.67 KiB) Downloaded 1070 times
cacti_graph_template_jvm_-_threads.xml
(21.77 KiB) Downloaded 1282 times
Last edited by mgupta on Sun Dec 13, 2009 9:32 pm, edited 2 times in total.
Manas
mgupta
Posts: 16
Joined: Thu Aug 13, 2009 4:29 pm
Location: Canada

JVM : Screenshots for the rest of the graphs.

Post by mgupta »

Creating a separate post since a post just allows 5 attachments.
Attachments
jvm_mem.png
jvm_mem.png (29.03 KiB) Viewed 36205 times
jvm_opf.png
jvm_opf.png (20.27 KiB) Viewed 36205 times
jvm_threads.png
jvm_threads.png (24.19 KiB) Viewed 36205 times
Manas
heynowjerry
Posts: 2
Joined: Wed Jan 13, 2010 2:52 pm

Re: JVM : Screenshots for the rest of the graphs.

Post by heynowjerry »

mgupta wrote:Creating a separate post since a post just allows 5 attachments.
Thanks...

Version 0.8.7d


Receiving this error for all 4 XML file after import.
Error: XML: Hash version does not exist.


Thanks in advance.
mgupta
Posts: 16
Joined: Thu Aug 13, 2009 4:29 pm
Location: Canada

Re: JVM : Screenshots for the rest of the graphs.

Post by mgupta »

I am on 0.8.7e. Could that be the problem?


[quote="heynowjerry"][quote="mgupta"]Creating a separate post since a post just allows 5 attachments.[/quote]

Thanks...

Version 0.8.7d


Receiving this error for all 4 XML file after import.
Error: XML: Hash version does not exist.


Thanks in advance.[/quote][b][/b]
Manas
heynowjerry
Posts: 2
Joined: Wed Jan 13, 2010 2:52 pm

Re: JVM : Screenshots for the rest of the graphs.

Post by heynowjerry »

Yep, the hashes are version specific, or so i've read.

Thanks anyways.we are eager to get up some templates for JVM monitoring..
mgupta wrote:I am on 0.8.7e. Could that be the problem?

heynowjerry wrote:
mgupta wrote:Creating a separate post since a post just allows 5 attachments.
Thanks...

Version 0.8.7d


Receiving this error for all 4 XML file after import.
Error: XML: Hash version does not exist.


Thanks in advance.
statistic fan
Posts: 1
Joined: Wed Jan 20, 2010 8:58 am

Post by statistic fan »

Thanks mgupta, your templates are very promising but after importing them, they aren't working for me.

The Memory statistics are fine, the rest won't generate. I checked the SNMP numbers and they all work.

e.g. the thread numbers:

Code: Select all

$ snmpwalk -m ./JVM-MANAGEMENT-MIB.mib -v1 -c public localhost .1.3.6.1.4.1.42.2.145.3.163.1.1.3.1.0
JVM-MANAGEMENT-MIB::jvmThreadCount.0 = Gauge32: 19
$ snmpwalk -m ./JVM-MANAGEMENT-MIB.mib -v1 -c public localhost .1.3.6.1.4.1.42.2.145.3.163.1.1.3.2.0
JVM-MANAGEMENT-MIB::jvmThreadDaemonCount.0 = Gauge32: 5
$ snmpwalk -m ./JVM-MANAGEMENT-MIB.mib -v1 -c public localhost .1.3.6.1.4.1.42.2.145.3.163.1.1.3.3.0
JVM-MANAGEMENT-MIB::jvmThreadPeakCount.0 = Counter32: 19
The used command for rrdtool is the following:

Code: Select all

/bin/rrdtool graph - \
--imgformat=PNG \
--start=1263909696 \
--end=1263996096 \
--title="server.onsteroids.org - JVM Threads" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--units-exponent=1 \
COMMENT:"From 2010/01/19 15\:01\:36 To 2010/01/20 15\:01\:36\c" \
COMMENT:"  \n" \
--vertical-label="Number of threads" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="/export/www/stats.myexample.org/htdocs/rra/server_onsteroids_org_jvm_daemonthreads_52.rrd":jvm_DaemonThreads:LAST \
DEF:b="/export/www/stats.myexample.org/htdocs/rra/server_onsteroids_org_jvm_threads_54.rrd":jvm_threads:LAST \
DEF:c="/export/www/stats.myexample.org/htdocs/rra/server_onsteroids_org_jvm_peak_threads_53.rrd":jvm_peak_threads:LAST \
LINE1:a#FF6044FF:"Daemon"  \
GPRINT:a:LAST:" Current\:%8.0lf"  \
GPRINT:a:AVERAGE:"Average\:%8.0lf"  \
GPRINT:a:MAX:"Maximum\:%8.0lf\n"  \
LINE2:b#00CF00FF:"Regular"  \
GPRINT:b:LAST:"Current\:%8.0lf"  \
GPRINT:b:AVERAGE:"Average\:%8.0lf"  \
GPRINT:b:MAX:"Maximum\:%8.0lf\n"  \
LINE3:c#FF0000FF:"Peak"  \
GPRINT:c:LAST:"   Current\:%8.0lf" 
Using it in my shell it gives me:

Code: Select all

ERROR: the RRD does not contain an RRA matching the chosen CF
I have a lot of graphs in my cacti and everything works except "JVM Num of Classes", "JVM OPF" and "JVM Threads" - "JVM Memory", as mentioned, works.


I'm relativly new to cacti and I don't find the solution, can you give me a hint please?


p.s. cacti-0.8.7e
mgupta
Posts: 16
Joined: Thu Aug 13, 2009 4:29 pm
Location: Canada

Missing CF

Post by mgupta »

You can try changing the CF in the graph template. There's a lot of other threads about missing CFs.
Manas
Snake007uk
Cacti User
Posts: 54
Joined: Fri Jun 24, 2005 10:16 am

Post by Snake007uk »

Change the CF from LAST to Average and the graphs will be ok.

Just wondering how to collect garbage collection.
linebacker2
Posts: 28
Joined: Fri May 08, 2009 11:34 am

No Such Object available on this agent at this OID

Post by linebacker2 »

when I do a snmpwalk I get the following result:

C:\usr\bin>snmpwalk -c public -v2c localhost:163 1.3.6.1.4.1.42.2.145.3.163.1.1.3.6
JVM-MANAGEMENT-MIB::jvmThreadCpuTimeMonitoring = No Such Object available on this agent at this OID

Anyone know why???


My Platform is Windows 2003 and have done the following to get Java apps monitored with Cacti.

- I have placed "JVM-MANAGEMENT-MIB.txt" in the mibs directory C:\usr\share\snmp\mibs
- changed the SNMP port TO run on port 163 instead of 161 under C:\WINDOWS\system32\drivers\etc\services
- Installed Net-SNMP and have it running as a service
- copied C:\Java\jdk-1.6-32\jre\lib\management\snmp.acl.template to copied C:\Java\jdk-1.6-32\jre\lib\management\snmp.acl
- set the following options in snmp.acl

acl ={

{

communities = public

access = read-only
managers = localhost

}

}

- Set the following parameters via wrapper.conf file for my java application:

wrapper.java.additional.1=-Dcom.sun.management.snmp.interface=0.0.0.0
wrapper.java.additional.2=-Dcom.sun.management.snmp.port=163
wrapper.java.additional.3=-Dcom.sun.management.snmp.acl=true
wrapper.java.additional.4=-Dcom.sun.management.snmp.acl.file=C:\Java\jdk-1.6-32\jre\lib\management\snmp.acl

- set the following in my snmpd.conf file:
proxy -v 2c -c public localhost:163 .1.3.6.1.4.1.42


This is a compilation of steps that I have researched and implemented.

What am I missing here? Any input would be greatly appreciated!
ILikeVoltron
Posts: 5
Joined: Wed Oct 19, 2011 12:44 pm

Re: Another JVM Monitoring template

Post by ILikeVoltron »

ianand0204 wrote:The template is fairly generic so hopefully it will work for everyone.

*NOTE* The screen shot is a little misleading. All values listed in the index are graphed, it just so happens that this screen shot was taken off an idle machine and thus doesn't display much difference in data.

This template was exported from cacti 0.8.6j so you will probably need the same version.[/url]

I'm having trouble importing this jvm_mem.xml.txt file you've attached, I get nothing back from cacti - no response it just uploads the file and returns nothing.

After some more digging I've found that when exporting a data template I don't see OIDs listed but the source xml file has OIDs as part of the template. In the ones coming out of cacti right now I see lots of <hash> tags but can't tell what they reference.

Something else to note here:

Code: Select all

[root@btr-inf-cacti cacti]# snmpwalk -v2c -c public test.host.com 1.3.6.1.4.1.42 | grep -i G1
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.100.1.2.2 = STRING: "G1 Young Generation"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.100.1.2.3 = STRING: "G1 Old Generation"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.110.1.2.2 = STRING: "G1 Eden"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.110.1.2.3 = STRING: "G1 Survivor"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.110.1.2.4 = STRING: "G1 Old Gen"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.110.1.2.5 = STRING: "G1 Perm Gen"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.120.1.2.2.2 = STRING: "G1 Young Generation"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.120.1.2.2.3 = STRING: "G1 Young Generation"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.120.1.2.3.2 = STRING: "G1 Old Generation"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.120.1.2.3.3 = STRING: "G1 Old Generation"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.120.1.2.3.4 = STRING: "G1 Old Generation"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.120.1.2.3.5 = STRING: "G1 Old Generation"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.120.1.3.2.2 = STRING: "G1 Eden"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.120.1.3.2.3 = STRING: "G1 Survivor"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.120.1.3.3.2 = STRING: "G1 Eden"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.120.1.3.3.3 = STRING: "G1 Survivor"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.120.1.3.3.4 = STRING: "G1 Old Gen"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.2.120.1.3.3.5 = STRING: "G1 Perm Gen"
SNMPv2-SMI::enterprises.42.2.145.3.163.1.1.4.20.1.2.3 = STRING: "-XX:+UseG1GC"
[root@btr-inf-cacti cacti]# snmpwalk -m /usr/share/snmp/mibs/JVM-MANAGEMENT-MIB.txt -v2c -c public test.host.com 1.3.6.1.4.1.42 | grep -i G1
JVM-MANAGEMENT-MIB::jvmMemManagerName.2 = STRING: G1 Young Generation
JVM-MANAGEMENT-MIB::jvmMemManagerName.3 = STRING: G1 Old Generation
JVM-MANAGEMENT-MIB::jvmMemPoolName.2 = STRING: G1 Eden
JVM-MANAGEMENT-MIB::jvmMemPoolName.3 = STRING: G1 Survivor
JVM-MANAGEMENT-MIB::jvmMemPoolName.4 = STRING: G1 Old Gen
JVM-MANAGEMENT-MIB::jvmMemPoolName.5 = STRING: G1 Perm Gen
JVM-MANAGEMENT-MIB::jvmMemMgrRelManagerName.2.2 = STRING: G1 Young Generation
JVM-MANAGEMENT-MIB::jvmMemMgrRelManagerName.2.3 = STRING: G1 Young Generation
JVM-MANAGEMENT-MIB::jvmMemMgrRelManagerName.3.2 = STRING: G1 Old Generation
JVM-MANAGEMENT-MIB::jvmMemMgrRelManagerName.3.3 = STRING: G1 Old Generation
JVM-MANAGEMENT-MIB::jvmMemMgrRelManagerName.3.4 = STRING: G1 Old Generation
JVM-MANAGEMENT-MIB::jvmMemMgrRelManagerName.3.5 = STRING: G1 Old Generation
JVM-MANAGEMENT-MIB::jvmMemMgrRelPoolName.2.2 = STRING: G1 Eden
JVM-MANAGEMENT-MIB::jvmMemMgrRelPoolName.2.3 = STRING: G1 Survivor
JVM-MANAGEMENT-MIB::jvmMemMgrRelPoolName.3.2 = STRING: G1 Eden
JVM-MANAGEMENT-MIB::jvmMemMgrRelPoolName.3.3 = STRING: G1 Survivor
JVM-MANAGEMENT-MIB::jvmMemMgrRelPoolName.3.4 = STRING: G1 Old Gen
JVM-MANAGEMENT-MIB::jvmMemMgrRelPoolName.3.5 = STRING: G1 Perm Gen
JVM-MANAGEMENT-MIB::jvmRTInputArgsItem.3 = STRING: -XX:+UseG1GC
Notice that when I don't pass the -m /path/JVM-MANAGEMENT-MIB.txt we don't get pretty names for the OIDs, could this be screwing stuff up?

I tried adding this to my snmpd.conf file in cacti mibs +ALL and I tried mibs +JVM-MANAGEMENT and a few others, but nothing seems to include this mib by default when running snmpwalk. Thanks in Advance.

edit: ok, so it looks like the file in question was actually a data_query and should be imported that way (as best I can tell) I started following the guide found here: http://forums.cacti.net/about4143.html but am still struggling a little bit to get everything to line up.
linebacker2
Posts: 28
Joined: Fri May 08, 2009 11:34 am

Re: Another JVM Monitoring template

Post by linebacker2 »

ILikeVoltron

Did you have any issues with adding individual JVM to monitor via this template when specifying a different SNMP port number?

I have set up the following setting for each individual JVM that I am trying to monitor, specifying an individual port for each JVM as shown below

com.sun.management.snmp.interface=0.0.0.0
com.sun.management.snmp.port=1161
com.sun.management.snmp.acl=true

I get successful results when doing an snmpwalk when specifying the JVM-MANAGEMENT MIBS both from the local machine and from an external machine so I know that the set up seems to be correct.

I am running into errors though when trying to add the individual host (The JVM instance) to monitor via cacti and adding the the unique port that I set up above for the JVM instance. IT gives me an "SNMP ERROR"

The only port values that Catci seems to be happy with are the SNMP and Net-SNMP port values (161 and 163)
Cacti Error.png
Cacti Error.png (292.19 KiB) Viewed 27100 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest