Zabbix Documentation 4.2

3.04.04.4 (current)| In development:5.0 (devel)| Unsupported:1.82.02.22.43.23.44.2Guidelines

User Tools

Site Tools


manual:config:items:itemtypes:jmx_monitoring

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
manual:config:items:itemtypes:jmx_monitoring [2017/10/17 06:16]
martins-v communication between Java gateway and the monitored JMX application should not be firewalled
manual:config:items:itemtypes:jmx_monitoring [2018/10/01 09:42] (current)
Line 8: Line 8:
  
 To retrieve the value of a particular JMX counter on a host, Zabbix server queries the Zabbix **Java gateway**, which in turn uses the [[http://​java.sun.com/​javase/​technologies/​core/​mntr-mgmt/​javamanagement/​|JMX management API]] to query the application of interest remotely. To retrieve the value of a particular JMX counter on a host, Zabbix server queries the Zabbix **Java gateway**, which in turn uses the [[http://​java.sun.com/​javase/​technologies/​core/​mntr-mgmt/​javamanagement/​|JMX management API]] to query the application of interest remotely.
- 
-<note warning>​Communication between Java gateway and the monitored JMX application should not be firewalled.</​note>​ 
  
 For more details and setup see the [[/​manual/​concepts/​java|Zabbix Java gateway]] section. For more details and setup see the [[/​manual/​concepts/​java|Zabbix Java gateway]] section.
 +
 +<note warning>​Communication between Java gateway and the monitored JMX application should not be firewalled.</​note>​
  
 === Enabling remote JMX monitoring for Java application === === Enabling remote JMX monitoring for Java application ===
Line 59: Line 59:
 == Configuring JMX interface == == Configuring JMX interface ==
  
-You begin by creating a JMX-type interface on the host of interest:+You begin by creating a JMX-type interface on the host of interest.\\
  
 {{jmx_interface.png?​600|}} {{jmx_interface.png?​600|}}
 +
 +All mandatory input fields are marked with a red asterisk. ​
  
 == Adding JMX agent item == == Adding JMX agent item ==
  
-For each JMX counter you are interested in you add **JMX agent** item attached to that interface. ​+For each JMX counter you are interested in you add **JMX agent** item attached to that interface.\\ 
  
 The key in the screenshot below says ''​%%jmx["​java.lang:​type=Memory","​HeapMemoryUsage.used"​]%%''​. The key in the screenshot below says ''​%%jmx["​java.lang:​type=Memory","​HeapMemoryUsage.used"​]%%''​.
  
-{{jmx_item.png|}}+{{jmx_item.png?600|}} 
 + 
 +All mandatory input fields are marked with a red asterisk. ​
  
 The fields that require specific information for JMX items are: The fields that require specific information for JMX items are:
Line 81: Line 85:
 If you wish to monitor a Boolean counter that is either "​true"​ or "​false",​ then you specify type of information as "​Numeric (unsigned)"​ and select "​Boolean to decimal"​ preprocessing step in the Preprocessing tab. Server will store Boolean values as 1 or 0, respectively. If you wish to monitor a Boolean counter that is either "​true"​ or "​false",​ then you specify type of information as "​Numeric (unsigned)"​ and select "​Boolean to decimal"​ preprocessing step in the Preprocessing tab. Server will store Boolean values as 1 or 0, respectively.
  
-== JMX item keys in more detail ==+=== JMX item keys in more detail ​===
  
-**Simple attributes**+== Simple attributes ​==
  
 An MBean object name is nothing but a string which you define in your Java application. An attribute name, on the other hand, can be more complex. In case an attribute returns primitive data type (an integer, a string etc.) there is nothing to worry about, the key will look like this: An MBean object name is nothing but a string which you define in your Java application. An attribute name, on the other hand, can be more complex. In case an attribute returns primitive data type (an integer, a string etc.) there is nothing to worry about, the key will look like this:
Line 91: Line 95:
 In this example an object name is "​com.example:​Type=Hello",​ attribute name is "​weight"​ and probably the returned value type should be "​Numeric (float)"​. In this example an object name is "​com.example:​Type=Hello",​ attribute name is "​weight"​ and probably the returned value type should be "​Numeric (float)"​.
  
-**Attributes returning composite data**+== Attributes returning composite data ==
  
 It becomes more complicated when your attribute returns composite data. For example: your attribute name is "​apple"​ and it returns a hash representing its parameters, like "​weight",​ "​color"​ etc. Your key may look like this: It becomes more complicated when your attribute returns composite data. For example: your attribute name is "​apple"​ and it returns a hash representing its parameters, like "​weight",​ "​color"​ etc. Your key may look like this:
Line 100: Line 104:
  
   jmx[com.example:​Type=Hello,​fruits.apple.weight]   jmx[com.example:​Type=Hello,​fruits.apple.weight]
-\\  + 
-**Problem with dots**+== Problem with dots ==
  
 So far so good. But what if an attribute name or a hash key contains dot symbol? Here is an example: So far so good. But what if an attribute name or a hash key contains dot symbol? Here is an example:
Line 116: Line 120:
  
   jmx[com.example:​Type=Hello,​all\.fruits.apple.total\.weight]   jmx[com.example:​Type=Hello,​all\.fruits.apple.total\.weight]
-\\  
-**Other issues** 
  
-A backslash character should be escaped ​as well:+== Other issues == 
 + 
 +A backslash character ​in an attribute name should be escaped:
  
   jmx[com.example:​type=Hello,​c:​\\documents]   jmx[com.example:​type=Hello,​c:​\\documents]
  
-If the object name or attribute name contains spaces or commas double-quote it: +For handling any other special characters in JMX item key, please see the item key format ​[[/​manual/​config/​items/​item/​key##​parameter_-_quoted_string|section]].
- +
-  jmx["​com.example:​Type=Hello","​fruits.apple.total weight"​]+
  
 This is actually all there is to it. Happy JMX monitoring! This is actually all there is to it. Happy JMX monitoring!
  
 +== Non-primitive data types ==
 +
 +Since Zabbix 4.0.0 it is possible to work with custom MBeans returning non-primitive data types, which override the **toString()** method.
 +
 +=== Custom endpoint example with JBoss EAP 6.4 ===
 +
 +Custom endpoints allow working with different transport protocols other than the default RMI.
 +
 +To illustrate this possibility,​ let's try to configure JBoss EAP 6.4 monitoring as an example. First, let's make some assumptions:​
 +
 +  * You have already installed Zabbix Java gateway. If not, then you can do it in accordance with the [[:​manual/​concepts/​java|documentation]].
 +  * Zabbix server and Java gateway are installed with the prefix /usr/local/
 +  * JBoss is already installed in /​opt/​jboss-eap-6.4/​ and is running in standalone mode
 +  * We shall assume that all these components work on the same host
 +  * Firewall and SELinux are disabled (or configured accordingly)
 +
 +Let's make some simple settings in zabbix_server.conf:​
 +
 +  JavaGateway=127.0.0.1
 +  StartJavaPollers=5
 +
 +And in the zabbix_java/​settings.sh configuration file (or zabbix_java_gateway.conf):​
 +
 +  START_POLLERS=5
 +
 +Check that JBoss listens to its standard management port:
 +
 +  $ netstat -natp | grep 9999
 +  tcp        0      0 127.0.0.1:​9999 ​         0.0.0.0:​* ​              ​LISTEN ​     10148/java
 +
 +Now let's create a host with JMX interface 127.0.0.1:​9999 in Zabbix.
 +
 +{{:​manual:​config:​items:​itemtypes:​jmx_jboss_example.png?​600|}}
 +
 +As we know that this version of JBoss uses the the JBoss Remoting protocol instead of RMI, we may mass update the JMX endpoint parameter in our JMX template accordingly:​
 +
 +  service:​jmx:​remoting-jmx://​{HOST.CONN}:​{HOST.PORT}
 +
 +{{:​manual:​config:​items:​itemtypes:​jmx_jboss_example3.png?​600|}}
 +
 +Let's update the configuration cache:
 +  $ /​usr/​local/​sbin/​zabbix_server -R config_cache_reload
 +
 +Note that you may encounter an error first.
 +
 +{{:​manual:​config:​items:​itemtypes:​jmx_jboss_example4.png?​600|}}
 +
 +"​Unsupported protocol: remoting-jmx"​ means that Java gateway does not know how to work with the specified protocol. That can be fixed by creating a ~/​needed_modules.txt file with the following content:
 +
 +  jboss-as-remoting
 +  jboss-logging
 +  jboss-logmanager
 +  jboss-marshalling
 +  jboss-remoting
 +  jboss-sasl
 +  jcl-over-slf4j
 +  jul-to-slf4j-stub
 +  log4j-jboss-logmanager
 +  remoting-jmx
 +  slf4j-api
 +  xnio-api
 +  xnio-nio</​pre>​
 +
 +and then executing the command:
 +
 +  $ for i in $(cat ~/​needed_modules.txt);​ do find /​opt/​jboss-eap-6.4 -iname ${i}*.jar -exec cp {} /​usr/​local/​sbin/​zabbix_java/​lib/​ \; ; done
 +
 +Thus, Java gateway will have all the necessary modules for working with jmx-remoting. What's left is to restart the Java gateway, wait a bit and if you did everything right, see that JMX monitoring data begin to arrive in Zabbix:
 +
 +{{:​manual:​config:​items:​itemtypes:​jmx_jboss_example5.png?​600|}}