Remote monitoring : querying jvm heap

Hi all,
Happy new year to all of you, I wish you the best for 2023 !

I’m setting up a basic remote probe/monitoring system of our servers, mostly oriented to check communication/performance from Lucee to other hosts/platform (SQL, ElasticSearch, Kafka, File Server …) and of course Lucee’s health.
To do so, each Lucee Server has a template that is queried from our monitoring server.
I would like to add (java heap) memory usage : is there a simple way to query this, basically as it is done in Admin homepage ? (It doesn’t have to be graphic at all; raw data would be perfect).

So if you have a hint, thanks in advance !
A.

Don’t forget to tell us about your stack!

OS: Windows
Lucee Version: 5.3.9.166
Java Version / Tomcat Version: Bundled with 5.3.9.166

Yes, it’s possible to get that info from Java APIs, here’s an example: cfmetrics/memory.cfm at master · foundeo/cfmetrics · GitHub

3 Likes

remember, Lucee is open source

1 Like

I think lucee has a native function that does that…

Like @Zackster said, the source is there and it seems to happen at:

That charProcess.cfm is called by:

1 Like

In chartProcess.cfm, there is this:

<cfset heap = variables.printMemory(getmemoryUsage("heap"),false)>

And in printMemory():

<cfset var max=evaluate(ValueList(arguments.usage.max,'+'))>

But that seems flawed because the max value of some of the memory subtypes may be -1, e.g. on my production server, GetMemoryUsage("heap") returns:

name used init max
G1 Eden Space 564133888 56623104 -1
G1 Old Gen 53705400 1017118720 1073741824
G1 Survivor Space 9437 0 -1

I’m guessing -1 means unlimited based on max allocated memory via -Xmx?

Either way, shouldn’t the -1 values be excluded from the sum?

I realize the end result is no difference in the % used because max is off by only 2 bytes, but hey I’m a perfectionist when it comes to the intentions of an algorithm. :wink: