From: Jeremy Katz Date: Wed, 25 Sep 2013 18:36:48 +0000 (-0400) Subject: Fix handling of 127.0.0.1 instead of localhost for *sql plugins X-Git-Tag: collectd-5.5.0~339^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F441%2Fhead;p=thirdparty%2Fcollectd.git Fix handling of 127.0.0.1 instead of localhost for *sql plugins The mysql and postgresql plugins have special handling if you use localhost as your hostname. Sometimes you need to use 127.0.0.1 instead and want to not have that make changes to the hostname for the metrics. --- diff --git a/src/mysql.c b/src/mysql.c index d15a055fe..6337ab4d1 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -287,6 +287,7 @@ static void set_host (mysql_database_t *db, char *buf, size_t buflen) { if ((db->host == NULL) || (strcmp ("", db->host) == 0) + || (strcmp ("127.0.0.1", db->host) == 0) || (strcmp ("localhost", db->host) == 0)) sstrncpy (buf, hostname_g, buflen); else diff --git a/src/postgresql.c b/src/postgresql.c index 1eaf6bd38..16e539a02 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -571,6 +571,7 @@ static int c_psql_exec_query (c_psql_database_t *db, udb_query_t *q, } if (C_PSQL_IS_UNIX_DOMAIN_SOCKET (db->host) + || (0 == strcmp (db->host, "127.0.0.1")) || (0 == strcmp (db->host, "localhost"))) host = hostname_g; else