summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0b350ce)
raw | patch | inline | side by side (parent: 0b350ce)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 1 Feb 2009 22:09:08 +0000 (23:09 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 1 Feb 2009 22:13:54 +0000 (23:13 +0100) |
This query parameter expands to the interval collectd is using.
src/collectd.conf.pod | patch | blob | history | |
src/postgresql.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 00c7ed356bd0e9fff9210d7189ff6d6fe8998850..67fe3b631415bc654ce4f3614309c69a1ce8b521 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
This is a deprecated synonym for B<Statement>. It will be removed in version 5
of collectd.
-=item B<Param> I<hostname>|I<database>|I<username>
+=item B<Param> I<hostname>|I<database>|I<username>|I<interval>
Specify the parameters which should be passed to the SQL query. The parameters
are referred to in the SQL query as B<$1>, B<$2>, etc. in the same order as
The username used to connect to the database.
+=item I<interval>
+
+The interval collectd is using (as specified by the B<Interval> option).
+
=back
Please note that parameters are only supported by PostgreSQL's protocol
diff --git a/src/postgresql.c b/src/postgresql.c
index bb2f0d28e99c1c1ebab8540e006e64b81c181e7d..2814cc4ad6f3263ff7b10ca239662514b65d2d94 100644 (file)
--- a/src/postgresql.c
+++ b/src/postgresql.c
C_PSQL_PARAM_HOST = 1,
C_PSQL_PARAM_DB,
C_PSQL_PARAM_USER,
+ C_PSQL_PARAM_INTERVAL,
} c_psql_param_t;
typedef struct {
c_psql_query_t *query)
{
char *params[db->max_params_num];
+ char interval[64];
int i;
assert (db->max_params_num >= query->params_num);
case C_PSQL_PARAM_USER:
params[i] = db->user;
break;
+ case C_PSQL_PARAM_INTERVAL:
+ ssnprintf (interval, sizeof (interval), "%i", interval_g);
+ params[i] = interval;
+ break;
default:
assert (0);
}
param = C_PSQL_PARAM_DB;
else if (0 == strcasecmp (param_str, "username"))
param = C_PSQL_PARAM_USER;
+ else if (0 == strcasecmp (param_str, "interval"))
+ param = C_PSQL_PARAM_INTERVAL;
else {
log_err ("Invalid parameter \"%s\".", param_str);
return 1;