The configuration is grouped into sections
A sample file is below
jmxmonitor.groups=group1 # Stop port and key - telnet to this port and send key to stop it jmxmonitor.stopport=18001 jmxmonitor.stopkey=stop jmxmonitor.localJmx=service:jmx:rmi://127.0.0.1:18002/jndi/rmi://127.0.0.1:18003/jmxrmi/ jmxmonitor.localRmiPort=18003 # Group 1 Configuration # Poll interval in milliseconds jmxmonitor.group1.interval=5000 # Path to monitor configuration jmxmonitor.group1.monitorConfiguration=src/test/resources/jmxLocalMonitoringTestMonitor.properties # Path to expressions jmxmonitor.group1.expressionConfiguration=src/test/resources/jmxLocalMonitoringTestExpression.properties
The key settings are
The monitor configuration file defines the *data* being gathered from the monitoring targets. Each file can monitor N urls. For each URL it will gather N attributes containing data. The attributes being gathered can be simple data types OR java objects. This will depend on whoever wrote the JMX MBean you are monitoring.
The way you find out about these attributes is to connect JConsole (or similar) to the JVM and browse them.
jmxmonitor.connections=url1 jmxmonitor.url1.url=service:jmx:rmi://127.0.0.1:18002/jndi/rmi://127.0.0.1:18003/jmxrmi/ jmxmonitor.url1.heap.objectName=java.lang:type=Memory jmxmonitor.url1.heap.attribute=HeapMemoryUsage jmxmonitor.url1.ping.objectName=uk.co.gidley.jmxmonitor:type=Bean1[*] jmxmonitor.url1.ping.discriminator=Discriminator jmxmonitor.url1.ping.attribute=Ping
JMX Monitor gathers all the objects in the monitors file and then exposes them to a scripting enviroment to output results.
The scripting language is *Javascript* (as implemented by the JVM). The scripts are stored in a configuration file.
jmxmonitor.heap="Heap Used " + heap.get("used") jmxmonitor.ping1="Ping 1 " + ping.get("1") jmxmonitor.ping2="Ping 2 " + ping.get("2")
In the case of discriminated objects (see above) the object exposed will be a map keyed by the discriminator.
The output of JMX Monitor is routed via logback. Logback is a logging library that supports a range of output formats (including file, db, console, mail, JMS).
There are essentially 2 sets of logs
All the logs are configured by a logback.xml file. If using the service the default is in /opt/etc/logback.xml. If using the commandline a default is shipped in the jar, but you should override by passing -Dlogback.configurationFile=/path/to/config.xml
JMX Monitor output to the logger 'uk.co.gidley.jmxmonitor'. It is recommended logging on INFO level somewhere to diagnose issues.
Expressions are output to 'monitoringgroup.GROUP_NAME'. If is recommended to write these with rolling file appenders.