[collectd] Mysql Patch on 4.6.2

Sebastian Harl sh at tokkee.org
Wed Apr 22 16:51:54 CEST 2009


Hi Rodolphe,

On Wed, Apr 22, 2009 at 04:10:10PM +0200, Rodolphe Quiedeville wrote:
> We evaluate collectd for internal use in our global monitoring system.
> For that we need to monitor mysql locks, so as collectd doesn't do this
> I wrote a little patch. This patch is based on 4.6.2 version and modify
> only src/mysql.c, hope you'll find it usefull. If this patch is
> acceptable please feel free to integrate it in your next release.

Thanks for your patch!

IIrc, this has been requested before but nobody stepped up to provide a
patch so far, so this is very appreciated. See two rather minor comments
below.

> diff -pur collectd-4.6.2/src/mysql.c collectd-4.6.2-mine/src/mysql.c
> --- collectd-4.6.2/src/mysql.c	2009-03-18 11:55:39.000000000 +0100
> +++ collectd-4.6.2-mine/src/mysql.c	2009-04-22 15:50:50.000000000 +0200
> @@ -225,6 +227,23 @@ static void traffic_submit (counter_t rx
>  	plugin_dispatch_values (&vl);
>  } /* void traffic_submit */
>  
> +static void locks_submit (counter_t immediate, counter_t waited)
> +{
> +	value_t values[2];
> +	value_list_t vl = VALUE_LIST_INIT;
> +
> +	values[0].counter = immediate;
> +	values[1].counter = waited;

I'd use a data type with one DS and use "immediate" and "waited" as type
instance.

> @@ -328,6 +350,13 @@ static int mysql_read (void)
>  			else if (strcmp (key, "Threads_created") == 0)
>  				threads_created = val;
>  		}
> +		else if (strncmp (key, "Table_", 6) == 0)

You could even use "Table_locks_" and then ...

> +		{
> +			if (strcmp (key, "Table_locks_immediate") == 0)
> +				locks_immediate  = val;

... use something like strcmp (key + strlen("Table_locks_", "immediate")

However, I don't think that matters really. In fact, I'd assume that
most / some compilers are able to optimize that appropriately - at least
in GCC, str*cmp() should be built-in functions.

> diff -pur collectd-4.6.2/src/types.db collectd-4.6.2-mine/src/types.db
> --- collectd-4.6.2/src/types.db	2009-03-18 11:55:39.000000000 +0100
> +++ collectd-4.6.2-mine/src/types.db	2009-04-22 16:02:24.000000000 +0200
> @@ -69,6 +69,7 @@ memory			value:GAUGE:0:281474976710656
>  multimeter		value:GAUGE:U:U
>  mysql_commands		value:COUNTER:0:U
>  mysql_handler		value:COUNTER:0:U
> +mysql_locks		immediate:COUNTER:0:U, waited:COUNTER:0:U

See my first comment: this would then be something like:

  mysql_locks		value:COUNTER:0:U

Cheers,
Sebastian

-- 
Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/

Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety.         -- Benjamin Franklin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20090422/55b62d96/attachment.pgp 


More information about the collectd mailing list