X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fmysql.c;h=9b8d6cf3aba8c97117f50e7c934fd008f44b8b33;hb=8391a4430d5dffea44898adb628a5bcdbcfe31ba;hp=db38a4b00cde26057aed301b3a22a67b1e144237;hpb=a82395b57384541152423862bcf44c0db7789641;p=collectd.git diff --git a/src/mysql.c b/src/mysql.c index db38a4b0..9b8d6cf3 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -65,9 +65,6 @@ typedef struct mysql_database_s mysql_database_t; /* }}} */ static int mysql_read (user_data_t *ud); -void mysql_read_default_options(struct st_mysql_options *options, - const char *filename, const char *group); - static void mysql_database_free (void *arg) /* {{{ */ { mysql_database_t *db; @@ -116,13 +113,12 @@ static int mysql_config_database (oconfig_item_t *ci) /* {{{ */ return (-1); } - db = (mysql_database_t *) malloc (sizeof (*db)); + db = calloc (1, sizeof (*db)); if (db == NULL) { - ERROR ("mysql plugin: malloc failed."); + ERROR ("mysql plugin: calloc failed."); return (-1); } - memset (db, 0, sizeof (*db)); /* initialize all the pointers */ db->alias = NULL; @@ -742,7 +738,7 @@ static int mysql_read (user_data_t *ud) key = row[0]; val = atoll (row[1]); - if (strncmp (key, "Com_", + if (strncmp (key, "Com_", strlen ("Com_")) == 0) { if (val == 0ULL) @@ -750,18 +746,18 @@ static int mysql_read (user_data_t *ud) /* Ignore `prepared statements' */ if (strncmp (key, "Com_stmt_", strlen ("Com_stmt_")) != 0) - counter_submit ("mysql_commands", - key + strlen ("Com_"), + counter_submit ("mysql_commands", + key + strlen ("Com_"), val, db); } - else if (strncmp (key, "Handler_", + else if (strncmp (key, "Handler_", strlen ("Handler_")) == 0) { if (val == 0ULL) continue; - counter_submit ("mysql_handler", - key + strlen ("Handler_"), + counter_submit ("mysql_handler", + key + strlen ("Handler_"), val, db); } else if (strncmp (key, "Qcache_", @@ -778,7 +774,7 @@ static int mysql_read (user_data_t *ud) else if (strcmp (key, "Qcache_queries_in_cache") == 0) qcache_queries_in_cache = (gauge_t) val; } - else if (strncmp (key, "Bytes_", + else if (strncmp (key, "Bytes_", strlen ("Bytes_")) == 0) { if (strcmp (key, "Bytes_received") == 0) @@ -786,7 +782,7 @@ static int mysql_read (user_data_t *ud) else if (strcmp (key, "Bytes_sent") == 0) traffic_outgoing += val; } - else if (strncmp (key, "Threads_", + else if (strncmp (key, "Threads_", strlen ("Threads_")) == 0) { if (strcmp (key, "Threads_running") == 0) @@ -898,8 +894,19 @@ static int mysql_read (user_data_t *ud) } else if (strncmp (key, "Sort_", strlen ("Sort_")) == 0) { - counter_submit ("mysql_sort", key + strlen ("Sort_"), - val, db); + if (strcmp (key, "Sort_merge_passes") == 0) + counter_submit ("mysql_sort_merge_passes", NULL, val, db); + else if (strcmp (key, "Sort_rows") == 0) + counter_submit ("mysql_sort_rows", NULL, val, db); + else if (strcmp (key, "Sort_range") == 0) + counter_submit ("mysql_sort", "range", val, db); + else if (strcmp (key, "Sort_scan") == 0) + counter_submit ("mysql_sort", "scan", val, db); + + } + else if (strncmp (key, "Slow_queries", strlen ("Slow_queries")) == 0) + { + counter_submit ("mysql_slow_queries", NULL , val, db); } } mysql_free_result (res); res = NULL;