X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmysql.c;h=fccaedbdc891eb42a7aceaec38dc468370f54ba7;hb=d4a0ba8ef40bbdd52be4ad73d7064171aeed155e;hp=a928172b51126abbb64cb093ca8bd90a171b5f6a;hpb=4566cb8eac15eb7d438087583c3048ccf00c3c6b;p=collectd.git diff --git a/src/mysql.c b/src/mysql.c index a928172b..fccaedbd 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -36,59 +36,6 @@ /* TODO: Understand `Select_*' and possibly do that stuff as well.. */ -static data_source_t data_source_counter[1] = -{ - {"value", DS_TYPE_COUNTER, 0, NAN} -}; - -static data_set_t ds_commands = -{ - "mysql_commands", 1, data_source_counter -}; - -static data_set_t ds_handler = -{ - "mysql_handler", 1, data_source_counter -}; - -static data_source_t data_source_qcache[5] = -{ - {"hits", DS_TYPE_COUNTER, 0, NAN}, - {"inserts", DS_TYPE_COUNTER, 0, NAN}, - {"not_cached", DS_TYPE_COUNTER, 0, NAN}, - {"lowmem_prunes", DS_TYPE_COUNTER, 0, NAN}, - {"queries_in_cache", DS_TYPE_GAUGE, 0, NAN} -}; - -static data_set_t ds_qcache = -{ - "mysql_qcache", 5, data_source_qcache -}; - -static data_source_t data_source_threads[4] = -{ - {"running", DS_TYPE_GAUGE, 0, NAN}, - {"connected", DS_TYPE_GAUGE, 0, NAN}, - {"cached", DS_TYPE_GAUGE, 0, NAN}, - {"created", DS_TYPE_COUNTER, 0, NAN} -}; - -static data_set_t ds_threads = -{ - "mysql_threads", 4, data_source_threads -}; - -static data_source_t data_source_octets[2] = -{ - {"rx", DS_TYPE_COUNTER, 0, 4294967295.0}, - {"tx", DS_TYPE_COUNTER, 0, 4294967295.0} -}; - -static data_set_t ds_octets = -{ - "mysql_octets", 2, data_source_octets -}; - #if MYSQL_HAVE_READ static const char *config_keys[] = { @@ -113,14 +60,12 @@ static MYSQL *getconnection (void) static int wait_for = 0; static int wait_increase = 60; - int step; - if (state != 0) { int err; if ((err = mysql_ping (con)) != 0) { - syslog (LOG_WARNING, "mysql_ping failed: %s", mysql_error (con)); + WARNING ("mysql_ping failed: %s", mysql_error (con)); state = 0; } else @@ -130,11 +75,9 @@ static MYSQL *getconnection (void) } } - step = atoi (COLLECTD_STEP); - if (wait_for > 0) { - wait_for -= step; + wait_for -= interval_g; return (NULL); } @@ -145,14 +88,14 @@ static MYSQL *getconnection (void) if ((con = mysql_init (con)) == NULL) { - syslog (LOG_ERR, "mysql_init failed: %s", mysql_error (con)); + ERROR ("mysql_init failed: %s", mysql_error (con)); state = 0; return (NULL); } if (mysql_real_connect (con, host, user, pass, db, 0, NULL, 0) == NULL) { - syslog (LOG_ERR, "mysql_real_connect failed: %s", mysql_error (con)); + ERROR ("mysql_real_connect failed: %s", mysql_error (con)); state = 0; return (NULL); } @@ -190,7 +133,7 @@ static void counter_submit (const char *type, const char *type_instance, vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "mysql"); strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); @@ -213,7 +156,7 @@ static void qcache_submit (counter_t hits, counter_t inserts, vl.values = values; vl.values_len = 5; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "mysql"); plugin_dispatch_values ("mysql_qcache", &vl); @@ -233,7 +176,7 @@ static void threads_submit (gauge_t running, gauge_t connected, gauge_t cached, vl.values = values; vl.values_len = 4; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "mysql"); plugin_dispatch_values ("mysql_threads", &vl); @@ -250,7 +193,7 @@ static void traffic_submit (counter_t rx, counter_t tx) vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname); + strcpy (vl.host, hostname_g); strcpy (vl.plugin, "mysql"); plugin_dispatch_values ("mysql_octets", &vl); @@ -291,14 +234,14 @@ static int mysql_read (void) if (mysql_real_query (con, query, query_len)) { - syslog (LOG_ERR, "mysql_real_query failed: %s\n", + ERROR ("mysql_real_query failed: %s\n", mysql_error (con)); return (-1); } if ((res = mysql_store_result (con)) == NULL) { - syslog (LOG_ERR, "mysql_store_result failed: %s\n", + ERROR ("mysql_store_result failed: %s\n", mysql_error (con)); return (-1); } @@ -383,12 +326,6 @@ static int mysql_read (void) void module_register (void) { - plugin_register_data_set (&ds_commands); - plugin_register_data_set (&ds_handler); - plugin_register_data_set (&ds_qcache); - plugin_register_data_set (&ds_threads); - plugin_register_data_set (&ds_octets); - #if MYSQL_HAVE_READ plugin_register_config ("mysql", config, config_keys, config_keys_num); plugin_register_read ("mysql", mysql_read);