[collectd] Tomcat plugin

Justo Alonso justo.alonso at gmail.com
Mon Dec 10 13:03:13 CET 2007


Hi !
    I attach a source for a tomcat stats plugin. This plugin get an url and
parse the results with libxml2 (need libcurl and libxml2). Collects stats
for memory (max, free, total), garbage collectors (times and time), threads
by connector (max, count, idle), request by connector (requests, errors,
bytes) and workers state by connector. In the configuration, you have
"instance", "url", "user", "password", "cacert". You must define first
instance, and the other options is related to it. You can define one or more
instances (if you have 2 tomcats on the same machine). P.E

<plugin tomcat>
    instance "blog"
    url "http://localhost:8080/collectd/stats"
    instance "web"
    url "http://localhost:9090/collect/stats"
    user "stats"
    password "**************"
</plugin>

this define 2 instances on the plugin, "blog" and "web", blog don't have
user/password and "web" have it.

On the tomcat side, you need install a collectd servlet. This servlet get
stats from mbeans (as manager/status) and the result is a xml with the info
(please consider security needs of your platform. To me RemoteAddrValve for
localhost is ok). This servlet is a modification of manager/status, so it's
under Apache license.

TODO
   - tomcat_read return values
   - tomcat_buffer have fix size, maybe a realloc ??
   - tomcat_instances have fix size, dinamyc list ??

comments ??
thanks,
justo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.verplant.org/pipermail/collectd/attachments/20071210/8d47f1c3/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tomcat.c
Type: text/x-csrc
Size: 15107 bytes
Desc: not available
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20071210/8d47f1c3/attachment-0001.c 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: webapp.collectd.tgz
Type: application/x-gzip
Size: 17834 bytes
Desc: not available
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20071210/8d47f1c3/attachment-0001.bin 


More information about the collectd mailing list