From f40ae90cb8cc3be204ca992f65dd0160baa2c08d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rodolphe=20Qui=C3=A9devillel?= Date: Thu, 23 Apr 2009 09:16:08 +0200 Subject: [PATCH] mysql plugin: Add `lock' statistics. Hi, 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. Regards, -- Rodolphe Quiedeville www.bearstech.com --- src/mysql.c | 9 +++++++++ src/types.db | 1 + 2 files changed, 10 insertions(+) diff --git a/src/mysql.c b/src/mysql.c index ca5c525d..ca364b6c 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -4,6 +4,7 @@ * Copyright (C) 2008 Mirko Buffoni * Copyright (C) 2009 Doug MacEachern * Copyright (C) 2009 Sebastian tokkee Harl + * Copyright (C) 2009 Rodolphe Quiédeville * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -23,6 +24,7 @@ * Mirko Buffoni * Doug MacEachern * Sebastian tokkee Harl + * Rodolphe Quiédevillel **/ #include "collectd.h" @@ -792,6 +794,13 @@ static int mysql_read (user_data_t *ud) else if (strcmp (key, "Threads_created") == 0) threads_created = val; } + else if (strncmp (key, "Table_locks_", 12) == 0) + { + if (val == 0ULL) + continue; + + counter_submit ("mysql_locks", key + 12, val, db); + } } mysql_free_result (res); res = NULL; diff --git a/src/types.db b/src/types.db index e07329c2..f8b2f81f 100644 --- a/src/types.db +++ b/src/types.db @@ -70,6 +70,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 value:COUNTER:0:U mysql_log_position value:COUNTER:0:4294967295 mysql_octets rx:COUNTER:0:4294967295, tx:COUNTER:0:4294967295 mysql_qcache hits:COUNTER:0:U, inserts:COUNTER:0:U, not_cached:COUNTER:0:U, lowmem_prunes:COUNTER:0:U, queries_in_cache:GAUGE:0:U -- 2.11.0