Support | Forums | Apps | Logscape.com

Collector - JMX

The collector capable of running Logscape apps, and due to this can be used to collect metrics from your JMX Endpoints. Using a simple GroovyScript we will create an app to query a JMX endpoint, and put that data into the Logscape Cloud.

For a guide on how to build your own Logscape apps, you can visit the App Introduction Page.

Querying a JMX endpoint

To query the JMX endpoint we'll use a simple groovy script to query a specific mbean, and log the output.

import groovy.jmx.builder.*
 
def propertyMissing(String name) {}
 
pout = pout == null ? System.out : pout
perr = perr == null ? System.err : perr
 
def stdOut = pout
def stdErr = perr
 
def connection = new JmxBuilder().client(port: PORT, host: HOST_ADDRESS)
connection.connect()
 
def mbeanConnection = connection.MBeanServerConnection
 
objectName="YOUR_OBJECT_NAME"
def mbean = new GroovyMBean(mbeanConnection, objectName)
 
pout << mbean.[YOUR_M_BEAN_NAME]

This script will connect to the endpoint, request a bean, and then output this to Logscape.

After creating a working groovy script, it's time to design the .bundle file, the bundle gives Logscapes jobs to run relating to the app.

The Bundle file

<Bundle name="ProjectSymphonyApp" version="1.0" system="false">
<status>UNINSTALLED</status>
	<owner>info@logscape.com</owner>
	<services>
		<Service>
			<name>YOUR_SERVICE_NAME</name>
			<resourceSelection>YOUR_FILTER</resourceSelection>
			<fork>true</fork>
			<background>true</background>
			<instanceCount>-1</instanceCount>
			<pauseSeconds>YOUR_PAUSE</pauseSeconds>
			<script>YOUR_GROOVY_SCRIPT.groovy</script>
		</Service>
	</services>
</Bundle>

This bundle is a small section of a much larger bundle, but shows how to include your Groovy script.

To finish, simply zip, and deploy your app as shown in the app guide, your collector will now collect stats from your JMX endpoint.