[collectd] Tomcat plugin

Florian Forster octo at verplant.org
Tue Dec 11 08:11:31 CET 2007


Hi Justo :)

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 ;)
-- 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..

>    - 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:

> 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..

Regards,
-octo
-- 
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20071211/c10a43bc/attachment.pgp 


More information about the collectd mailing list