X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmysql.c;h=30557f61bd0e7e662bf37eac10194327a763327f;hb=6ce771ab08db6f57d91836356bd3a1e1439b10e8;hp=9014e5ff2c31781b727526b0bea646f7e47820e1;hpb=bd66a09b35da21dcb405650ae4587bf2ca811438;p=collectd.git diff --git a/src/mysql.c b/src/mysql.c index 9014e5ff..30557f61 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -24,19 +24,14 @@ #include "plugin.h" #include "configfile.h" -#ifdef HAVE_MYSQL_MYSQL_H +#ifdef HAVE_MYSQL_H +#include +#elif defined(HAVE_MYSQL_MYSQL_H) #include #endif -#if HAVE_LIBMYSQLCLIENT -# define MYSQL_HAVE_READ 1 -#else -# define MYSQL_HAVE_READ 0 -#endif - /* TODO: Understand `Select_*' and possibly do that stuff as well.. */ -#if MYSQL_HAVE_READ static const char *config_keys[] = { "Host", @@ -133,8 +128,8 @@ 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_g); - strcpy (vl.plugin, "mysql"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin)); strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); plugin_dispatch_values (type, &vl); @@ -156,8 +151,8 @@ 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_g); - strcpy (vl.plugin, "mysql"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin)); plugin_dispatch_values ("mysql_qcache", &vl); } /* void qcache_submit */ @@ -176,8 +171,8 @@ 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_g); - strcpy (vl.plugin, "mysql"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin)); plugin_dispatch_values ("mysql_threads", &vl); } /* void threads_submit */ @@ -193,8 +188,8 @@ 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_g); - strcpy (vl.plugin, "mysql"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin)); plugin_dispatch_values ("mysql_octets", &vl); } /* void traffic_submit */ @@ -322,12 +317,9 @@ static int mysql_read (void) return (0); } /* int mysql_read */ -#endif /* MYSQL_HAVE_READ */ void module_register (void) { -#if MYSQL_HAVE_READ plugin_register_config ("mysql", config, config_keys, config_keys_num); plugin_register_read ("mysql", mysql_read); -#endif /* MYSQL_HAVE_READ */ } /* void module_register */