[collectd] Tomcat plugin

Justo Alonso justo.alonso at gmail.com
Tue Dec 18 12:45:08 CET 2007


On Dec 11, 2007 8:11 AM, Florian Forster <octo at verplant.org> wrote:

> Hi Justo :)

Hi Florian,
     This is a new version of tomcat plugin

>
> Thanks for your ``development peak'' at your new plugin :) I didn't have
> time to read all of your plugin, so the following is based on your email
> and a quick look at the read function ;)
>
> On Mon, Dec 10, 2007 at 01:03:13PM +0100, Justo Alonso wrote:
> > <plugin tomcat>
> >     instance "blog"
> >     url "http://localhost:8080/collectd/stats"
> >     instance "web"
> >     url "http://localhost:9090/collect/stats"
> >     user "stats"
> >     password "**************"
> > </plugin>
>
> I'd prefer if the order of the lines didn't make a difference. To get
> the following syntax you'd need to use the ``complex configuration''
> scheme. Don't worry about it too much, though - since it's a bit tricky
> to parse I'll write a patch against your code, so you don't have to dig
> into this ;)


don't worry ... I have read de csnmp  source plugin and  make it on tomcat
plugin

>
> -- 8< --
>  <Plugin tomcat>
>   <Instance "blog">
>     Url "http://localhost:8080/collectd/stats"
>   </Instance>
>   <Instance "web">
>     Url "http://localhost:9090/collect/stats"
>     User "stats"
>     Password "**************"
>   </Instance>
>  </Plugin>
> -- >8 --
>
> > On the tomcat side, you need install a collectd servlet.
> > [...]
> > This servlet is a modification of manager/status, so it's under Apache
> > license.
>
> What sets this new servlet apart from the already existing servlet? As
> far as I've seen you can append `?XML=true' to the servlet bundled with
> Tomcat and get XML output from that, too..
>
> > TODO
> >    - tomcat_buffer have fix size, maybe a realloc ??
>
> Do as you think it's practical. If the size of the status page could
> differ a lot (depending on the setup, I don't think it'll differ between
> calls much) then realloc would be better. Such a change could be back-
> ported to the apache plugin, too..


it's ok .. tomcat_buffer don't have fixed size now ... realloc it on
curl_callback


>
> >    - tomcat_instances have fix size, dinamyc list ??
>
> Yes, please.
>
> Since we talked about this in another thread here's how I'd return an
> error from the read function in this case:


I use the llist_* functions on utils_llist file


> > static int tomcat_read (void)
> > {
>        int success = 0;
> >       for( x = 0; x <= tomcat_instances_num; x++ ) {
> >               tomcat_instance_t *ti = tomcat_instances[x];
> >
>                /* If this happens there's a bug in the code and it's
>                 * safer not to do anything. */
> >               if( ti == NULL ) {
> >                       ERROR ("tomcat: read, instance object is null.");
> >                       return (-1);
> >               }
> >
>                /* ... */
> >
> >               tomcat_buffer_len = 0;
> >               if (curl_easy_perform (ti->curl) != 0)
> >               {
> >                       ERROR ("tomcat: curl_easy_perform failed for
> instance %s: %s",
> >                                       ti->name,
> >                                       tomcat_curl_error);
>                        continue;
> >               }
> >
>                /* ... */
>                success++;
> >       }
> >
>        return ((success > 0) ? 0 : -1)
> > } /* int tomcat_read */


>
> This means: If ALL instances fail, -1 is returned. If at least one
> instance succeeded, return 0. Thus the plugin returns -1 if something is
> seriously broken and it's likely it'll fail again next time it's
> called..


ok, implemented now ...

read it and send me any comments ...

>
>
> Regards,
> -octo


thanks,
justo

>
> --
> Florian octo Forster
> Hacker in training
> GnuPG: 0x91523C3D
> http://verplant.org/
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFHXjgjOIGYkRnzlcMRAn5SAKCXD0eEC9hTON1PJSF2noB1XG0NNgCfQYQO
> aO4oxn0sBEHUdWJMXlos5OU=
> =NX4+
> -----END PGP SIGNATURE-----
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.verplant.org/pipermail/collectd/attachments/20071218/e04bbcd8/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tomcat.c
Type: text/x-csrc
Size: 17764 bytes
Desc: not available
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20071218/e04bbcd8/attachment-0001.c 


More information about the collectd mailing list