Skip to content

Commit

Permalink
postgresql plugin: Added support for using the db instance as query p…
Browse files Browse the repository at this point in the history
…arameter.
  • Loading branch information
tokkee committed Oct 18, 2012
1 parent 0a125de commit bd84c0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/collectd.conf.pod
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions src/postgresql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bd84c0f

Please sign in to comment.