postgresql plugin: Added support for using the db instance as query parameter.
authorSebastian Harl <sh@tokkee.org>
Thu, 18 Oct 2012 11:13:58 +0000 (13:13 +0200)
committerSebastian Harl <sh@tokkee.org>
Thu, 18 Oct 2012 11:13:58 +0000 (13:13 +0200)
src/collectd.conf.pod
src/postgresql.c

index 1a1339e..e24282c 100644 (file)
@@ -3604,6 +3604,11 @@ used, the parameter expands to "localhost".
 
 The name of the database of the current connection.
 
+=item I<instance>
+
+The name of the database plugin instance. See the B<Instance> option of the
+database specification below for details.
+
 =item I<username>
 
 The username used to connect to the database.
index 5f29bec..675505b 100644 (file)
@@ -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;