<html><body>

<p>Hi Everybody, </p>
<p>many of you may be aggregating jmx counters using the java plugin. This is cumbersome in many ways, since the piggybacking the java interpreter onto collectd increases its otherwise rather thin footprint onto the system a lot. Next problem is, you need to have exactly the same versions etc. in your java interpreter with the libraries it loads as the server runs which it queries. A good solution to solve this, is to load jolokia into the java servlet engine (http://jolokia.org) and have your jmx counters queried via HTTP and get the replies in json.</p>
<p>Fine, you may think, the curl_json plugin can work with this. However jolokias output doesn't work well with this:</p>
<pre><em>[ { "value" : 252480941283, "status" : 200, "request" : { "mbean" : "java.lang:type=Threading", "type" : "read", "attribute" : "CurrentThreadCpuTime" }, "timestamp" : 1391166299 }, { "request" : { "mbean" : "java.lang:type=Threading", "attribute" : "PeakThreadCount", "type" : "read" }, "status" : 200, "timestamp" : 1391166299, "value" : 80 },</em><br /><em>...</em><br /><em>]</em></pre>
<p>So I started hacking the curl_json plugin to work with this data; its mainly picking 'Value', 'request->mbean', 'request->attribute'. Once a set of the three items has been found in the json, try to find a configuration for it, and if found, parse it, and send it:</p>
<p><em><Plugin curl_jolokia></em><br /><em>  <URL "http://localhost/jolokia/"></em><br /><em>  Post = "[{\"mbean\" : \"java.lang:type=Threading\", \"type\" : \"read\", \"config\" : {}, \"attribute\" : \"CurrentThreadCpuTime\"},{   \"attribute\" : \"PeakThreadCount\",   \"config\" : {},   \"mbean\" : \"java.lang:type=Threading\",   \"type\" : \"read\"},{   \"attribute\" : \"DaemonThreadCount\",   \"config\" : {},   \"mbean\" : \"java.lang:type=Threading\",   \"type\" : \"read\"},{   \"attribute\" : \"TotalStartedThreadCount\",   \"type\" : \"read\",   \"mbean\" : \"java.lang:type=Threading\",   \"config\" : {}},{   \"mbean\" : \"java.lang:type=Threading\",   \"type\" : \"read\",   \"config\" : {},   \"attribute\" : \"ThreadCount\"},{   \"type\" : \"read\",   \"mbean\" : \"java.lang:type=Threading\",   \"config\" : {},   \"attribute\" : \"CurrentThreadUserTime\"}]"</em><br /><em>  <Key "DaemonThreadCount" ></em><br /><em>       Attribute "DaemonThreadCount"</em><br /><em>       MBean "java.lang:type=Threading"    </em><br /><em>       Type "counter" </em><br /><em>  </Key></em><br /><em>  <Key "PeakThreadCount" ></em><br /><em>       Attribute "PeakThreadCount"</em><br /><em>       MBean "java.lang:type=Threading"    </em><br /><em>       Type "counter" </em><br /><em>  </Key></em><br /><em>  </URL></em><br /><em></Plugin></em></p>
<p> </p>
<p>This curl_json plugin is far less flexible now, so one should rather name it curl_jolokia. Since there are UIs more clever at generating the queries to send to jolokia (i.e. http://hawt.io) I simply took their post message and did not implement something which would generate this json.</p>
<p>Comments?</p>
<p> </p>
<p>Cheers,</p>
<p>Wilfried Goesgens</p>
<p> </p>
<p> </p>
</body></html>