While making the move from Zabbix3x to Zabbix4x, I've been adding a few bits and tweaking the LLD rules, etc. While inspecting available beans exposed by a Tomcat instance, I noticed ava.lang:type=GarbageCollector MXBean has a LastGcInfo attribute that is a CompositeData value, which interesting has some sub-values called memoryUsageAfterGc and memoryUsageBeforeGc, which expose the javax.management.openmbean.TabularData interface. Each table exposes each heap and non-heap memory pool using the name of its java.lang:type=MemoryPool as the TabularData key. The memory pool is a CompositeData value that can be further examined with Attribute dot notation. for example:
Unfortunately, Zabbix didn't support tabular datatypes. After a bit of research, I stumbled across this post from 2015 where some guy had submitted a patch to support, enabling tabular datatypes https://support.zabbix.com/browse/ZBXNEXT-2727. This didn't work for every scenario including grabbing the attributes above. I've taken this patch and tweaked it to work for the Composite structure above. It' would be nice to see this included at some point
I'm not a developer so it may need cleaning up but I can confirm this works on v4.2.
You can get the attribute the same way as you normally would using dot notation. For eg: jmx["java.lang:type=GarbageCollector,name=G1 Young Generation","LastGcInfo.memoryUsageBeforeGc.Code Cache.max"]




PATCH: http://dpaste.com/3Z9MGX8
If it doesn't make it in, at least people have the option to use my patch if they like.
Code:
LastGcInfo.memoryUsageAfterGc = {
( G1 Old Gen ) = {
key = G1 Old Gen;
value = {
committed = 937426944;
init = 1017118720;
max = 3221225472;
used = 827967488;
};
};
( G1 Perm Gen ) = {
key = G1 Perm Gen;
value = {
committed = 98566144;
init = 20971520;
max = 536870912;
used = 97732464;
};
};
( Code Cache ) = {
key = Code Cache;
value = {
committed = 11599872;
init = 2555904;
max = 50331648;
used = 11381888;
};
};
( G1 Eden Space ) = {
key = G1 Eden Space;
value = {
committed = 127926272;
init = 56623104;
max = -1;
used = 0;
};
};
( G1 Survivor Space ) = {
key = G1 Survivor Space;
value = {
committed = 8388608;
init = 0;
max = -1;
used = 8388608;
};
};
};
I'm not a developer so it may need cleaning up but I can confirm this works on v4.2.You can get the attribute the same way as you normally would using dot notation. For eg: jmx["java.lang:type=GarbageCollector,name=G1 Young Generation","LastGcInfo.memoryUsageBeforeGc.Code Cache.max"]
PATCH: http://dpaste.com/3Z9MGX8
If it doesn't make it in, at least people have the option to use my patch if they like.