[collectd] MySQL 5 'show status' command

James Byers jbyers at jbyers.com
Sat Apr 1 11:26:14 CEST 2006


We've had collectd happily generating stats for a few months now without
a hitch.  Recently we upgraded from MySQL 4.1 to 5.0 and found that
MySQL stats mostly disappeared.

It turns out that after MySQL 5.0.2, 'SHOW STATUS' defaults to data for
the current session only.  The correct command is 'SHOW GLOBAL STATUS', 
which unfortunately is not backward compatible.  I've attached a patch 
against 3.8.2 that seems to work with MySQL 4.1 and 5.0.

Thanks,
James
http://wikispaces.com

--- src/mysql.c.old     2006-04-01 09:09:18.400057568 +0000
+++ src/mysql.c 2006-03-31 18:07:51.000000000 +0000
@@ -365,7 +365,11 @@
         if ((con = getconnection ()) == NULL)
                 return;

-       query = "SHOW STATUS";
+        if (mysql_get_server_version (con) < 50002) {
+               query = "SHOW STATUS";
+        } else {
+               query = "SHOW GLOBAL STATUS";
+        }
         query_len = strlen (query);

         if (mysql_real_query (con, query, query_len))




More information about the Collectd mailing list