X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmysql.c;h=a2394137532d8fe54560eb1bc69a30d99b6357d5;hb=c6557cb8950f50a41a1decfb34439b060e2fd371;hp=db38a4b00cde26057aed301b3a22a67b1e144237;hpb=5047407e6c0ca8b53bf1629144396702cd18cf08;p=collectd.git diff --git a/src/mysql.c b/src/mysql.c index db38a4b0..a2394137 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,15 @@ 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); + } } mysql_free_result (res); res = NULL;