Могуће је открити све JMX MBeans или MBean атрибути или да наведете образац за откривање ових објеката.
Обавезно је разумети разлику између MBean-а и MBean-а атрибути за конфигурацију правила откривања. MBean је објекат који може представљати уређај, апликацију или било који ресурс који треба да буде управљао.
На пример, постоји MBean који представља веб сервер. Његово атрибути су број конекција, број нити, временско ограничење захтева, http кеш датотека, употреба меморије, итд. Изражавање ове мисли на људском свеобухватним језиком можемо дефинисати апарат за кафу као MBean који има следеће атрибуте које треба пратити: количину воде по шољи, просечна потрошња воде за одређени временски период, број зрна кафе потребна по шољици, зрна кафе и време допуњавања воде итд.
In discovery rule configuration, select JMX agent in the Type field.
Two item keys are supported for JMX object discovery - jmx.discovery[] and jmx.get[]:
Item key | |||
---|---|---|---|
Return value | Parameters | Comment | |
jmx.discovery[<discovery mode>,<object name>,<unique short description>] | |||
This item returns a JSON array with LLD macros describing MBean objects or their attributes. | discovery mode - one of the following: attributes (retrieve JMX MBean attributes, default) or beans (retrieve JMX MBeans) object name - object name pattern (see documentation) identifying the MBean names to be retrieved (empty by default, retrieving all registered beans) unique short description - a unique description that allows multiple JMX items with the same discovery mode and object name on the host (optional) |
Examples: → jmx.discovery - retrieve all JMX MBean attributes → jmx.discovery[beans] - retrieve all JMX MBeans → jmx.discovery[attributes,"*:type=GarbageCollector,name=*"] - retrieve all garbage collector attributes → jmx.discovery[beans,"*:type=GarbageCollector,name=*"] - retrieve all garbage collectors There are some limitations to what MBean properties this item can return based on limited characters that are supported in macro name generation (supported characters can be described by the following regular expression: A-Z0-9_\. ). So, for example, to discover MBean properties with a hyphenated word or non-ASCII characters, you need to use jmx.get[] . |
|
jmx.get[<discovery mode>,<object name>,<unique short description>] | |||
This item returns a JSON array with MBean objects or their attributes. Compared to jmx.discovery[] it does not define LLD macros. |
discovery mode - one of the following: attributes (retrieve JMX MBean attributes, default) or beans (retrieve JMX MBeans) object name - object name pattern (see documentation) identifying the MBean names to be retrieved (empty by default, retrieving all registered beans) unique short description - a unique description that allows multiple JMX items with the same discovery mode and object name on the host (optional) |
When using this item, it is needed to define custom low-level discovery macros, pointing to values extracted from the returned JSON using JSONPath. |
If no parameters are passed, all MBean attributes from JMX are requested. Not specifying parameters for JMX discovery or trying to receive all attributes for a wide range like *:type=*,name=*
may lead to potential performance problems.
This item returns a JSON object with low-level discovery macros describing MBean objects or attributes. For example, in the discovery of MBean attributes (reformatted for clarity):
[
{
"{#JMXVALUE}":"0",
"{#JMXTYPE}":"java.lang.Long",
"{#JMXOBJ}":"java.lang:type=GarbageCollector,name=PS Scavenge",
"{#JMXDESC}":"java.lang:type=GarbageCollector,name=PS Scavenge,CollectionCount",
"{#JMXATTR}":"CollectionCount"
},
{
"{#JMXVALUE}":"0",
"{#JMXTYPE}":"java.lang.Long",
"{#JMXOBJ}":"java.lang:type=GarbageCollector,name=PS Scavenge",
"{#JMXDESC}":"java.lang:type=GarbageCollector,name=PS Scavenge,CollectionTime",
"{#JMXATTR}":"CollectionTime"
},
{
"{#JMXVALUE}":"true",
"{#JMXTYPE}":"java.lang.Boolean",
"{#JMXOBJ}":"java.lang:type=GarbageCollector,name=PS Scavenge",
"{#JMXDESC}":"java.lang:type=GarbageCollector,name=PS Scavenge,Valid",
"{#JMXATTR}":"Valid"
},
{
"{#JMXVALUE}":"PS Scavenge",
"{#JMXTYPE}":"java.lang.String",
"{#JMXOBJ}":"java.lang:type=GarbageCollector,name=PS Scavenge",
"{#JMXDESC}":"java.lang:type=GarbageCollector,name=PS Scavenge,Name",
"{#JMXATTR}":"Name"
},
{
"{#JMXVALUE}":"java.lang:type=GarbageCollector,name=PS Scavenge",
"{#JMXTYPE}":"javax.management.ObjectName",
"{#JMXOBJ}":"java.lang:type=GarbageCollector,name=PS Scavenge",
"{#JMXDESC}":"java.lang:type=GarbageCollector,name=PS Scavenge,ObjectName",
"{#JMXATTR}":"ObjectName"
}
]
In the discovery of MBeans (reformatted for clarity):
[
{
"{#JMXDOMAIN}":"java.lang",
"{#JMXTYPE}":"GarbageCollector",
"{#JMXOBJ}":"java.lang:type=GarbageCollector,name=PS Scavenge",
"{#JMXNAME}":"PS Scavenge"
}
]
Следећи макрои су подржани за коришћење у правилу откривања филтер и прототипови ставки, покретача и графикона:
Macro | Description |
---|---|
Откриће MBean атрибута | |
{#JMXVALUE} | Вредност атрибута. |
{#JMXTYPE} | Тип атрибута. |
{#JMXOBJ} | Име објекта. |
{#JMXDESC} | Име објекта укључујући име атрибута. |
{#JMXATTR} | Име атрибута. |
Откриће MBeans-а | |
{#JMXDOMAIN} | MBean домен. (Zabbix резервисано име) |
{#JMXOBJ} | Име објекта. (Zabbix резервисано име) |
{#JMX<key property>} | MBean својства (као {#JMXTYPE}, {#JMXNAME}) (погледајте Ограничења испод). |
There are some limitations associated with the algorithm of creating LLD macro names from MBean property names:
A-Z0-9_\.
Please consider this jmx.discovery (with "beans" mode) example. MBean has the following properties defined (some of which will be ignored; see below):
As a result of JMX discovery, the following LLD macros will be generated:
Ignored properties are:
Let’s review two more practical examples of a LLD rule creation with the use of MBean. To understand the difference between a LLD rule collecting MBeans and a LLD rule collecting MBean attributes better please take a look at following table:
MBean1 | MBean2 | MBean3 |
MBean1Attribute1 | MBean2Attribute1 | MBean3Attribute1 |
MBean1Attribute2 | MBean2Attribute2 | MBean3Attribute2 |
MBean1Attribute3 | MBean2Attribute3 | MBean3Attribute3 |
This rule will return 3 objects: the top row of the column: MBean1, MBean2, MBean3.
For more information about objects please refer to supported macros table, Discovery of MBeans section.
Discovery rule configuration collecting MBeans (without the attributes) looks like the following:
The key used here:
All the garbage collectors without attributes will be discovered. As Garbage collectors have the same attribute set, we can use desired attributes in item prototypes the following way:
The keys used here:
LLD discovery rule will result in something close to this (items are discovered for two Garbage collectors):
This rule will return 9 objects with the following fields: MBean1Attribute1, MBean2Attribute1, MBean3Attribute1,MBean1Attribute2,MBean2Attribute2, MBean3Attribute2, MBean1Attribute3, MBean2Attribute3, MBean3Attribute3.
For more information about objects please refer to supported macros table, Discovery of MBean attributes section.
Discovery rule configuration collecting MBean attributes looks like the following:
The key used here:
All the garbage collectors with a single item attribute will be discovered.
In this particular case an item will be created from prototype for every MBean attribute. The main drawback of this configuration is that trigger creation from trigger prototypes is impossible as there is only one item prototype for all attributes. So this setup can be used for data collection, but is not recommended for automatic monitoring.
jmx.get[]
is similar to the jmx.discovery[]
item, but it does not turn Java object properties into low-level discovery macro names and therefore can return values without limitations that are associated with LLD macro name generation such as hyphens or non-ASCII characters.
When using jmx.get[]
for discovery, low-level discovery macros can be defined separately in the custom LLD macro tab of the discovery rule configuration, using JSONPath to point to the required values.
Discovery item: jmx.get[beans,"com.example:type=*,*"]
Response:
[
{
"object": "com.example:type=Hello,data-src=data-base,ключ=значение",
"domain": "com.example",
"properties": {
"data-src": "data-base",
"ключ": "значение",
"type": "Hello"
}
},
{
"object": "com.example:type=Atomic",
"domain": "com.example",
"properties": {
"type": "Atomic"
}
}
]
Discovery item: jmx.get[attributes,"com.example:type=*,*"]
Response:
[
{
"object": "com.example:type=*",
"domain": "com.example",
"properties": {
"type": "Simple"
}
},
{
"object": "com.zabbix:type=yes,domain=zabbix.com,data-source=/dev/rand,ключ=значение,obj=true",
"domain": "com.zabbix",
"properties": {
"type": "Hello",
"domain": "com.example",
"data-source": "/dev/rand",
"ключ": "значение",
"obj": true
}
}
]