Zabbix Documentation 3.4

2.23.04.04.2 (current)In development:4.4 (devel)Unsupported:1.82.02.43.23.4

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/07/12 13:43]
martins-v since Zabbix 3.4, you may discover MBeans and MBean attributes using low level discovery
manual:config:items:itemtypes:jmx_monitoring [2018/07/19 06:51]
martins-v some rewording
Line 1: Line 1:
-==== 14 JMX monitoring ====+====== 14 JMX monitoring ​======
  
 === Overview === === Overview ===
Line 9: Line 9:
 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>​See the respective manual section for setup and more details ​on Zabbix ​[[/​manual/​concepts/​java|Java gateway]].</​note>​+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 72: Line 74:
  
 |//​Type// ​        |Set **JMX agent** here.  | |//​Type// ​        |Set **JMX agent** here.  |
-|//​Key// ​         |The ''​jmx[]''​ item key contains two parameters:​\\ **object name** - the object name of an MBean;\\ **attribute name** - an MBean attribute name with optional composite data field names separated by dots.\\ See below for more detail on JMX item keys.\\ Since Zabbix 3.4, you may discover MBeans and MBean attributes using [[:​manual/​discovery/​low_level_discovery/​jmx|low-level discovery]]. ​ |+|//​Key// ​         |The ''​jmx[]''​ item key contains two parameters:​\\ **object name** - the object name of an MBean;\\ **attribute name** - an MBean attribute name with optional composite data field names separated by dots.\\ See below for more detail on JMX item keys.\\ Since Zabbix 3.4, you may discover MBeans and MBean attributes using a ''​jmx.discovery[]'' ​[[:​manual/​discovery/​low_level_discovery/​jmx|low-level discovery]] ​item.  |
 |//JMX endpoint// |You may specify a custom JMX endpoint. Make sure that JMX endpoint connection parameters match the JMX interface. This can be achieved by using {HOST.*} macros as done in the default JMX endpoint.\\ This field is supported since 3.4.0. {HOST.*} [[:​manual/​appendix/​macros/​supported_by_location|macros]] and user macros are supported. ​ | |//JMX endpoint// |You may specify a custom JMX endpoint. Make sure that JMX endpoint connection parameters match the JMX interface. This can be achieved by using {HOST.*} macros as done in the default JMX endpoint.\\ This field is supported since 3.4.0. {HOST.*} [[:​manual/​appendix/​macros/​supported_by_location|macros]] and user macros are supported. ​ |
 |//User name// ​  ​|Specify the user name, if you have configured authentication on your Java application.\\ User macros are supported. ​ | |//User name// ​  ​|Specify the user name, if you have configured authentication on your Java application.\\ User macros are supported. ​ |
Line 79: Line 81:
 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 89: Line 91:
 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 98: Line 100:
  
   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 114: Line 116:
  
   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 keyplease see [[/​manual/​config/​items/​item/​key##​parameter_-_quoted_string|this 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!
  
 +=== 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|}}