summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6a8d29a)
raw | patch | inline | side by side (parent: 6a8d29a)
author | Florian Forster <octo@collectd.org> | |
Fri, 14 Dec 2012 10:40:12 +0000 (11:40 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Fri, 14 Dec 2012 10:40:12 +0000 (11:40 +0100) |
src/apcups.c | patch | blob | history | |
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history |
diff --git a/src/apcups.c b/src/apcups.c
index 4fbbde63aad113dcbefdbc2db47e545ca3b5c241..dd535b15f966c0e17ebc29281f80723f068d80c1 100644 (file)
--- a/src/apcups.c
+++ b/src/apcups.c
/* Default values for contacting daemon */
static char *conf_host = NULL;
static int conf_port = NISPORT;
+/* Defaults to false for backwards compatibility. */
+static _Bool conf_report_seconds = 0;
static int global_sockfd = -1;
{
"Host",
"Port",
- NULL
+ "ReportSeconds"
};
-static int config_keys_num = 2;
+static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
static int net_shutdown (int *fd)
{
else if (strcmp ("LINEFREQ", key) == 0)
apcups_detail->linefreq = value;
else if (strcmp ("TIMELEFT", key) == 0)
+ {
+ /* Convert minutes to seconds if requested by
+ * the user. */
+ if (conf_report_seconds)
+ value *= 60.0;
apcups_detail->timeleft = value;
+ }
tokptr = strtok_r (NULL, ":", &toksaveptr);
} /* while (tokptr != NULL) */
}
conf_port = port_tmp;
}
+ else if (strcasecmp (key, "ReportSeconds") == 0)
+ {
+ if (IS_TRUE (value))
+ conf_report_seconds = 1;
+ else
+ conf_report_seconds = 0;
+ }
else
{
return (-1);
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index 87af1c96c390b53ba79a51356c14f46678ece771..a565a57948ec1c010bc39050435aa4b8466c484f 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
#<Plugin apcups>
# Host "localhost"
# Port "3551"
+# ReportSeconds true
#</Plugin>
#<Plugin ascent>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index f011dbcd0005934199d8ca7cc82928a37986b81c..b9f9549d223c1a0548609db6fd3dbac2a1067985 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
TCP-Port to connect to. Defaults to B<3551>.
+=item B<ReportSeconds> B<true|false>
+
+If set to B<true>, the time reported in the C<timeleft> metric will be
+converted to seconds. This is the recommended setting. If set to B<false>, the
+default for backwards compatibility, the time will be reported in minutes.
+
=back
=head2 Plugin C<ascent>