check tomcat memory

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: check tomcat memory

Post by mcapra »

Frédéric GRANAT wrote: When Check_tomcat.pl reports by example 1 Gb of memory used, the taskmanager reports, by the same time, 2,2 Gb for Tomcat process memory usage.
Effectively, the history of memory consumption is logged by NagiosXI, but the memory consumption doesn't match the values showed by the taskmanager for Tomcat process
I have explained this exact situation here:
mcapra wrote:One is reporting on the Windows environment (task manager), the other is reporting on the JVM (check_tomcat.pl).

The JVM can hold as much memory for its heap as the OS allows, or up to the -Xmx setting for its runtime. That doesn't necessarily mean the JVM's processes are using all of that heap in any given instant, though.
The JVM might want to "reserve" memory for a variety of reasons.

In the above scenario, the JVM has requested 2,2GB from the OS (Windows) for its heap. Of that 2,2GB in the heap, the Tomcat process inside that JVM is currently using 1GB. Why is the JVM reserving an additional 1,2GB for its heap? I cannot say, but isn't not exactly uncommon practice especially with Tomcat. I'd wager someone told Tomcat's JVM to do that by modifying the -Xms value at run-time.

If you don't care about JVM technicals and specifics, you could use a different plugin and monitor the Tomcat process as it exists on the OS level, rather than as it exists inside a JVM. There's pros and cons to both approaches. Both NSClient++ and check_wmi_plus should have the necessary tools to get memory usage of a given process. NCPA should have it with the release of 3.0.0.
Former Nagios employee
https://www.mcapra.com/
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

Re: check tomcat memory

Post by Frédéric GRANAT »

Hi mcapra ,
Ok thanks, I understand now :
Taskmgr : shows the all memory configured for Java
Nagios : shows the memory consumption of Tomcat ("inside Java memory")

Is there a way to monitor Tomcat process memory consumption with a tool install on my windows server ? (I would like to verify that Tomcat memory consumption is correct on my Nagios check).

Rgds

Frederic
swolf

Re: check tomcat memory

Post by swolf »

Hi Frederic,

You should be able to verify internal JVM statistics using jconsole.exe

If you don't have jconsole.exe, it should come bundled with the Java JDK, which you can get here. It probably will not come up in Windows search, but it should be installed at C:\Program Files\Java\jdk-9.0.1\bin (or whatever directory you used to install the JDK).
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

Re: check tomcat memory

Post by Frédéric GRANAT »

Hi,
I'v just tried jconsole.
It doesn't detect the Tomcat process and running jconsole with PID of Tomcat process says it doesn't know that process

Do you have any idea that could help ?
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: check tomcat memory

Post by npolovenko »

FrédéricGRANAT, I'm not an expert in Tomcat but seems like you need to connect Tomcat to the Jconsole. Take a look at this tutorial:
https://community.jaspersoft.com/wiki/h ... ng-service
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

Re: check tomcat memory

Post by Frédéric GRANAT »

Hi,
Thanks, I succeeded in monitoring via jconsole (and it corresponds to the values monitored by nagios)
What's strange is that check_tomcat didn't detect the java.lang.OutOfMemoryError : Java heap space (error message logged in Tomcat log)
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: check tomcat memory

Post by npolovenko »

Frédéric GRANAT, It could be that there was a bump in memory usage as a result of check_tomcat using the JConsole. I'd probably consider increasing the memory limit for tomcat. Take a look at these errors and try to find when and how often they're occurring.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

Re: check tomcat memory

Post by Frédéric GRANAT »

Hi,
Frédéric GRANAT, It could be that there was a bump in memory usage as a result of check_tomcat using the JConsole
=> I'm talking about an error that occured 8 days ago (so no link with check_tomcat using jconsole).
I increased the memory allocated to java (from 2Gb to 4 Gb).
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: check tomcat memory

Post by npolovenko »

Frédéric GRANAT, I see. Let us know if this issue returns.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Frédéric GRANAT
Posts: 445
Joined: Mon Nov 19, 2012 11:36 am

Re: check tomcat memory

Post by Frédéric GRANAT »

Hi,
Ok you can close the post.

Thanks for your help

Frederic
Locked