Es posible descubrir todos los atributos JMX MBeans o de MBean o para especificar un patrón para el descubrimiento de estos objetos.
Es obligatorio comprender la diferencia entre un MBean y un atributo MBean para la configuración de reglas de descubrimiento. Un MBean es un objeto que puede representar un dispositivo, una aplicación o cualquier recurso que deba ser administrado.
Por ejemplo, hay un MBean que representa un servidor web. Sus atributos son recuento de conexiones, recuento de subprocesos, tiempo de espera de solicitud, caché de archivos http, uso de memoria, etc. Expresando este pensamiento en un lenguaje humano comprensible podemos decir que una máquina de café es como un MBean que tiene los siguientes atributos a monitorear: cantidad de agua por taza, consumo medio de agua durante un determinado período de tiempo, número de granos de café requeridos por taza, granos de café y tiempo de recarga de agua, etc.
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 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[] .Supported since Zabbix Java gateway 3.4. |
|
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. Supported since Zabbix Java gateway 4.4. |
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"
}
]
Las siguientes macros son compatibles para su uso en el filtro de la regla de descubrimiento y en prototipos de métricas, iniciadores y gráficos:
Macro | Descripción |
---|---|
Descubrimiento de atributos MBean | |
{#JMXVALUE} | Valor del atributo. |
{#JMXTYPE} | Tipo de atributo. |
{#JMXOBJ} | Nombre del objeto. |
{#JMXDESC} | Nombre del objeto, incluido el nombre del atributo. |
{#JMXATTR} | Nombre del atributo. |
Descubrimiento de MBeans | |
{#JMXDOMAIN} | Dominio MBean. (Nombre reservado de Zabbix) |
{#JMXOBJ} | Nombre del objeto. (Nombre reservado de Zabbix) |
{#JMX<key property>} | Propiedades de MBean (como {#JMXTYPE}, {#JMXNAME}) (consulte las limitaciones a continuación). |
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:
As a result of JMX discovery, the following LLD macros will be generated:
Ignored properties are:
Repasemos dos ejemplos prácticos más de creación de reglas LLD con el uso de MBean. Para comprender la diferencia entre una recopilación de reglas LLD MBeans y una regla LLD que recopila mejor los atributos de MBean, por favor eche un vistazo a la siguiente tabla:
MBean1 | MBean2 | MBean3 |
MBean1Atributo1 | MBean2Atributo1 | MBean3Atributo1 |
MBean1Atributo2 | MBean2Atributo2 | MBean3Atributo2 |
MBean1Atributo3 | MBean2Atributo3 | MBean3Atributo3 |
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[]
es similar a la métrica jmx.discovery[]
, pero no convierte las propiedades de los objetos Java en nombres de macros de descubrimiento de bajo nivel y por lo tanto, puede devolver valores sin limitaciones que son asociados con la generación de nombres de macros LLD, como guiones o caracteres no ASCII.
Cuando se utiliza jmx.get[]
para el descubrimiento, se pueden utilizar macros de descubrimiento de bajo nivel definidas por separado en la pestaña de macro LLD personalizada de la configuración de reglas de descubrimiento, usando JSONPath para apuntar a los valores requeridos.
Métrica de descubrimiento: jmx.get[beans,"com.example:type=*,*"]
Respuesta:
[
{
"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"
}
}
]
Métrica de descubrimiento: jmx.get[attributes,"com.example:type=*,*"]
Respuesta:
[
{
"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
}
}
]