[collectd] curl Jolokia plugin - first try

Wilfried Goesgens willi at citadel.org
Wed Feb 5 22:20:02 CET 2014


Hi Everybody,   

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.  

Fine, you may think, the curl_json plugin can work with this. However
jolokias output doesn't work well with this:  /[ { "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 },/
/.../
/]/  

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:  

/<Plugin curl_jolokia>/
/  <URL "http://localhost/jolokia/">/
/  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\"}]"/
/  <Key "DaemonThreadCount" >/
/       Attribute "DaemonThreadCount"/
/       MBean "java.lang:type=Threading"    /
/       Type "counter" /
/  </Key>/
/  <Key "PeakThreadCount" >/
/       Attribute "PeakThreadCount"/
/       MBean "java.lang:type=Threading"    /
/       Type "counter" /
/  </Key>/
/  </URL>/
/</Plugin>/  

   

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.  

Comments?  

   

Cheers,  

Wilfried Goesgens  

   

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.verplant.org/pipermail/collectd/attachments/20140205/bb3f5e85/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: curl_json.c
Type: text/x-csrc
Size: 23469 bytes
Desc: not available
URL: <http://mailman.verplant.org/pipermail/collectd/attachments/20140205/bb3f5e85/attachment-0001.c>


More information about the collectd mailing list