From: Sebastian Harl Date: Thu, 18 Oct 2012 11:13:58 +0000 (+0200) Subject: postgresql plugin: Added support for using the db instance as query parameter. X-Git-Tag: collectd-5.2.0~31 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=bd84c0f19f7010e33cedfd0549250135c73f6c00;p=collectd.git postgresql plugin: Added support for using the db instance as query parameter. --- diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 1a1339e6..e24282c3 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -3604,6 +3604,11 @@ used, the parameter expands to "localhost". The name of the database of the current connection. +=item I + +The name of the database plugin instance. See the B option of the +database specification below for details. + =item I The username used to connect to the database. diff --git a/src/postgresql.c b/src/postgresql.c index 5f29becb..675505bb 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -95,6 +95,7 @@ typedef enum { C_PSQL_PARAM_DB, C_PSQL_PARAM_USER, C_PSQL_PARAM_INTERVAL, + C_PSQL_PARAM_INSTANCE, } c_psql_param_t; /* Parameter configuration. Stored as `user data' in the query objects. */ @@ -347,6 +348,9 @@ static PGresult *c_psql_exec_query_params (c_psql_database_t *db, ? CDTIME_T_TO_DOUBLE (db->interval) : interval_g); params[i] = interval; break; + case C_PSQL_PARAM_INSTANCE: + params[i] = db->instance; + break; default: assert (0); } @@ -567,6 +571,8 @@ static int config_query_param_add (udb_query_t *q, oconfig_item_t *ci) data->params[data->params_num] = C_PSQL_PARAM_USER; else if (0 == strcasecmp (param_str, "interval")) data->params[data->params_num] = C_PSQL_PARAM_INTERVAL; + else if (0 == strcasecmp (param_str, "instance")) + data->params[data->params_num] = C_PSQL_PARAM_INSTANCE; else { log_err ("Invalid parameter \"%s\".", param_str); return 1;