Monitor Java JVM Heap Memory

To the Ipswitch web site

Ipswitch Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Monitor Java JVM Heap MemoryExpand / Collapse
Author
Message
Posted 4/23/2008 7:01:09 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 10/27/2008 4:22:43 PM
Posts: 11, Visits: 49
The company I work for develops Java applications.  I would like the ability to monitor the JVM Heap Memory.  Has anyone done anything like this?

There is a console supplied with the JDK (aptly named JConsole) which does this and it's run in the users login (requires a user to stay logged in) and doesn't have any alerting/reporting.  I would like to monitor the heap memory and when it hits a threashold to alert me.

Another option was to monitor it with the Java app itself and then put these items into the WUG database and have a custom WUG report?  Not sure if that is a viable option or not.

Any ideas/suggestions would be appreciated.

Chris

Post #43156
Posted 7/11/2008 9:34:45 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/23/2008 3:53:59 PM
Posts: 7, Visits: 19
We are having the same issue: we want to monitor the Java Heap usage on Linux machines. SNMP is installed on all Linux machines.

Any ideas / best practices would be appreciated.

Update:
good starting points to monitor JVM using SNMP:
http://java.sun.com/javase/6/docs/technotes/guides/management/snmp.html
http://blogs.sun.com/jmxetc/entry/what_is_the_jvm_snmp
http://gentoo-wiki.com/JVM_Monitoring_with_SNMP

-Avital
Post #45297
Posted 7/12/2008 5:07:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/23/2008 3:53:59 PM
Posts: 7, Visits: 19
Here's what we did so far:

1. enable snmpd on the Linux machine. Make sure that WUG can use it (monitor CPU, disk space etc...)

2. configure JVM SNMP to use the localhost interface (its default configuration). What we're actually doing is monitoring through the machine's snmpd, and it is proxying requests for the specific mib over to the jvm snmp agent over the localhost interface. This makes it so there is no interference between the agents. The main agent is the machine's agent, and any other agent running on the machine will be a slave agent to it.

More info here: http://gentoo-wiki.com/JVM_Monitoring_with_SNMP.

3. import the jvm snmp mib to WUG. Get it from:
http://java.sun.com/javase/6/docs/jre/api/management/JVM-MANAGEMENT-MIB.mib

4. jvmThreadCount (1.3.6.1.4.1.42.2.145.3.163.1.1.3.1 ) can be monitored using a simple SNMP performance monitor. In fact, any counter that is not of type Counter64 can be monitored. The problem is with the memory counters: The JVM SNMP MIB defines all memory counters as Counter64. However, this doesn't comply with the relevant RFC as those memory counters have Gauge behavior (they can go up and down rather than go only up - which confuses WUG). Hence, in order to monitor the memory usage of the JVM, we need to cast the counter to Integer type (another solution that is used in other snmp monitoring tools is to cast to Gauge64).

We need to define a custom performance monitor of type Active Script:
- From the Performance Monitor Library click New, select Active Script Performance Monitor
- Add reference variable, for example jvmMemoryHeapUsed (1.3.6.1.4.1.42.2.145.3.163.1.1.2.11), name the variable jvmMemoryHeapUsed.
- in the script text, write:

' this script is a vbscript that polls a Counter64 and saves it as Integer

'Sending log message to the WhatsUp Event Viewer
Context.LogMessage "Checking jvmMemoryHeapUsed on Address=" & Context.GetProperty("Address")

'Get the value of the reference variable
res = Context.GetReferenceVariable("jvmMemoryHeapUsed")

If res = Null Then
' Pass a non zero error code upon failure with an error message.
' The error message will be logged in the Performance Monitor Error Log
' and in the eventviewer.
Context.SetResult 1, "Failed to poll the reference variable."
Else
' Set the performance monitor value to graph
Context.SetValue res
End If

- name the new performance monitor and click Ok.
Post #45319
Posted 10/27/2008 4:23:52 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 10/27/2008 4:22:43 PM
Posts: 11, Visits: 49
Thanks so much for your posts on this.  We are going to look into your suggestions and comments and see how we fair.  Once we get a working solution, I will post back as well.
Post #48166
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Dave, Mark Singh, kevin r gillis, Jason Benton, Brandon Felger, Ben Henderson, Tripp Allen, Will Sansbury, Hush, FTPplanet.com, Hugh Garber, George Dailey, WUP-PM, mmulryan@ipswitch.com, mswimm

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 9:42am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.031. 10 queries. Compression Enabled.