From: Wilson Felipe Date: Mon, 4 Feb 2013 19:27:49 +0000 (-0800) Subject: mysql plugin: adding innodb counters X-Git-Tag: collectd-5.5.0~229^2~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bfd449eb7f6aaccdd3a9ccd1b816f551563a1ef6;p=collectd.git mysql plugin: adding innodb counters --- diff --git a/src/mysql.c b/src/mysql.c index a6b1e5e6..df1e7b67 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -54,6 +54,7 @@ struct mysql_database_s /* {{{ */ _Bool master_stats; _Bool slave_stats; + _Bool innodb_stats; _Bool slave_notif; _Bool slave_io_running; @@ -181,6 +182,8 @@ static int mysql_config_database (oconfig_item_t *ci) /* {{{ */ status = cf_util_get_boolean (child, &db->slave_stats); else if (strcasecmp ("SlaveNotifications", child->key) == 0) status = cf_util_get_boolean (child, &db->slave_notif); + else if (strcasecmp ("InnodbStats", child->key) == 0) + status = cf_util_get_boolean (child, &db->innodb_stats); else { WARNING ("mysql plugin: Option `%s' not allowed here.", child->key); @@ -679,6 +682,62 @@ static int mysql_read (user_data_t *ud) key + strlen ("Table_locks_"), val, db); } + else if (db->innodb_stats && strncmp (key, "Innodb_", strlen ("Innodb_")) == 0) + { + /* buffer pool */ + if (strcmp (key, "Innodb_buffer_pool_pages_data") == 0) + gauge_submit ("mysql_bpool_pages", "data", val, db); + else if (strcmp (key, "Innodb_buffer_pool_pages_dirty") == 0) + gauge_submit ("mysql_bpool_pages", "dirty", val, db); + else if (strcmp (key, "Innodb_buffer_pool_pages_flushed") == 0) + counter_submit ("mysql_bpool_counters", "flushed", val, db); + else if (strcmp (key, "Innodb_buffer_pool_pages_free") == 0) + gauge_submit ("mysql_bpool_pages", "free", val, db); + else if (strcmp (key, "Innodb_buffer_pool_pages_misc") == 0) + gauge_submit ("mysql_bpool_pages", "misc", val, db); + else if (strcmp (key, "Innodb_buffer_pool_pages_total") == 0) + gauge_submit ("mysql_bpool_pages", "total", val, db); + else if (strcmp (key, "Innodb_buffer_pool_read_ahead_rnd") == 0) + counter_submit ("mysql_bpool_counters", "read_ahead_rnd", val, db); + else if (strcmp (key, "Innodb_buffer_pool_read_ahead") == 0) + counter_submit ("mysql_bpool_counters", "read_ahead", val, db); + else if (strcmp (key, "Innodb_buffer_pool_read_ahead_evicted") == 0) + counter_submit ("mysql_bpool_counters", "read_ahead_evicted", val, db); + else if (strcmp (key, "Innodb_buffer_pool_read_requests") == 0) + counter_submit ("mysql_bpool_counters", "read_requests", val, db); + else if (strcmp (key, "Innodb_buffer_pool_reads") == 0) + counter_submit ("mysql_bpool_counters", "reads", val, db); + else if (strcmp (key, "Innodb_buffer_pool_write_requests") == 0) + counter_submit ("mysql_bpool_counters", "write_requests", val, db); + + /* data */ + if (strcmp (key, "Innodb_data_fsyncs") == 0) + counter_submit ("mysql_innodb_data", "fsyncs", val, db); + else if (strcmp (key, "Innodb_data_read") == 0) + counter_submit ("mysql_innodb_data", "read", val, db); + else if (strcmp (key, "Innodb_data_reads") == 0) + counter_submit ("mysql_innodb_data", "reads", val, db); + else if (strcmp (key, "Innodb_data_writes") == 0) + counter_submit ("mysql_bpool_counters", "writes", val, db); + else if (strcmp (key, "Innodb_data_written") == 0) + counter_submit ("mysql_innodb_data", "written", val, db); + + /* double write */ + else if (strcmp (key, "Innodb_dblwr_writes") == 0) + counter_submit ("mysql_innodb_dblwr", "writes", val, db); + else if (strcmp (key, "Innodb_dblwr_pages_written") == 0) + counter_submit ("mysql_innodb_dblwr", "written", val, db); + + /* rows */ + else if (strcmp (key, "Innodb_rows_deleted") == 0) + counter_submit ("mysql_innodb_rows", "deleted", val, db); + else if (strcmp (key, "Innodb_rows_inserted") == 0) + counter_submit ("mysql_innodb_rows", "inserted", val, db); + else if (strcmp (key, "Innodb_rows_read") == 0) + counter_submit ("mysql_innodb_rows", "read", val, db); + else if (strcmp (key, "Innodb_rows_updated") == 0) + counter_submit ("mysql_innodb_rows", "updated", val, db); + } } mysql_free_result (res); res = NULL; diff --git a/src/types.db b/src/types.db index 06f6fd2e..e24a78c0 100644 --- a/src/types.db +++ b/src/types.db @@ -105,6 +105,11 @@ mysql_handler value:DERIVE:0:U mysql_locks value:DERIVE:0:U mysql_log_position value:DERIVE:0:U mysql_octets rx:DERIVE:0:U, tx:DERIVE:0:U +mysql_bpool_pages value:GAUGE:0:U +mysql_bpool_counters value:DERIVE:0:U +mysql_innodb_data value:DERIVE:0:U +mysql_innodb_dblwr value:DERIVE:0:U +mysql_innodb_rows value:DERIVE:0:U nfs_procedure value:DERIVE:0:U nginx_connections value:GAUGE:0:U nginx_requests value:DERIVE:0:U