From: Mirko Buffoni Date: Wed, 29 Oct 2008 11:24:04 +0000 (+0100) Subject: mysql plugin: Allow configuration of `Port' and `Socket'. X-Git-Tag: collectd-4.6.0~160^2~2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=422c0afd40606e7f22304ea11086ea9e56da2579;p=collectd.git mysql plugin: Allow configuration of `Port' and `Socket'. Hi, I have a patch for mysql collectd library. The patch allow to specify also Port and Socket parameters for those who have a non-standard configuration of mysql. It's very straightforward. If accepted, there is only to change documentation and config file to reflect the new parameters. Enjoy Mirko Signed-off-by: Florian Forster --- diff --git a/src/mysql.c b/src/mysql.c index 4e72b5bf..08df3fa8 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -38,14 +38,18 @@ static const char *config_keys[] = "User", "Password", "Database", + "Port", + "Socket", NULL }; -static int config_keys_num = 4; +static int config_keys_num = 6; static char *host = "localhost"; static char *user; static char *pass; static char *db = NULL; +static char *socket = NULL; +static int port = 0; static MYSQL *getconnection (void) { @@ -88,7 +92,7 @@ static MYSQL *getconnection (void) return (NULL); } - if (mysql_real_connect (con, host, user, pass, db, 0, NULL, 0) == NULL) + if (mysql_real_connect (con, host, user, pass, db, port, socket, 0) == NULL) { ERROR ("mysql_real_connect failed: %s", mysql_error (con)); state = 0; @@ -113,6 +117,10 @@ static int config (const char *key, const char *value) return ((pass = strdup (value)) == NULL ? 1 : 0); else if (strcasecmp (key, "database") == 0) return ((db = strdup (value)) == NULL ? 1 : 0); + else if (strcasecmp (key, "socket") == 0) + return ((socket = strdup (value)) == NULL ? 1 : 0); + else if (strcasecmp (key, "port") == 0) + return ((port = atoi (value)) == NULL ? 1 : 0); else return (-1); }