summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ec7ae67)
raw | patch | inline | side by side (parent: ec7ae67)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 19 Mar 2009 16:40:46 +0000 (17:40 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 19 Mar 2009 16:40:46 +0000 (17:40 +0100) |
The `Interval' option is not honored and can be used to set an arbitrary
interval for this plugin.
interval for this plugin.
src/collectd.conf.pod | patch | blob | history | |
src/onewire.c | patch | blob | history |
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index 8dd53caf07ab687d9efc605d82b5de7dfe5ce20f..19ca6c50442f3299fa3c914bd23f1b68548c733a 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
@@ -1771,6 +1771,11 @@ enables you to do that: By setting B<IgnoreSelected> to I<true> the effect of
B<Sensor> is inverted: All selected interfaces are ignored and all other
interfaces are collected.
+=item B<Interval> I<Seconds>
+
+Sets the interval in which all sensors should be read. If not specified, the
+global B<Interval> setting is used.
+
=back
B<EXPERIMENTAL!> The C<onewire> plugin is experimental, because it doesn't yet
diff --git a/src/onewire.c b/src/onewire.c
index c40d5ad73077c4243074d4ae27ff3424d76b4204..261457a1bb90cad631a236c8fc7014818b4f9c01 100644 (file)
--- a/src/onewire.c
+++ b/src/onewire.c
static int ow_family_features_num = STATIC_ARRAY_SIZE (ow_family_features);
static char *device_g = NULL;
+static int ow_interval = 0;
static const char *config_keys[] =
{
"Device",
"IgnoreSelected",
"Sensor",
+ "Interval"
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
sfree (device_g);
device_g = temp;
}
- else
+ else if (strcasecmp ("Interval", key) == 0)
{
- return (-1);
+ int tmp;
+ tmp = atoi (value);
+ if (tmp > 0)
+ ow_interval = tmp;
+ else
+ ERROR ("onewire plugin: Invalid `Interval' setting: %s", value);
}
-
- return (0);
-}
-
-static int cow_init (void)
-{
- int status;
-
- if (device_g == NULL)
+ else
{
- ERROR ("onewire plugin: cow_init: No device configured.");
return (-1);
}
- status = (int) OW_init (device_g);
- if (status != 0)
- {
- ERROR ("onewire plugin: OW_init(%s) failed: %i.", device_g, status);
- return (1);
- }
-
return (0);
-} /* int cow_init */
+}
static int cow_read_values (const char *path, const char *name,
const ow_family_features_t *family_info)
return (0);
} /* int cow_read_bus */
-static int cow_read (void)
+static int cow_read (user_data_t *ud __attribute__((unused)))
{
return (cow_read_bus ("/"));
} /* int cow_read */
return (0);
} /* int cow_shutdown */
+static int cow_init (void)
+{
+ int status;
+ struct timespec cb_interval;
+
+ if (device_g == NULL)
+ {
+ ERROR ("onewire plugin: cow_init: No device configured.");
+ return (-1);
+ }
+
+ status = (int) OW_init (device_g);
+ if (status != 0)
+ {
+ ERROR ("onewire plugin: OW_init(%s) failed: %i.", device_g, status);
+ return (1);
+ }
+
+ memset (&cb_interval, 0, sizeof (cb_interval));
+ if (ow_interval > 0)
+ cb_interval.tv_sec = (time_t) ow_interval;
+
+ plugin_register_complex_read ("onewire", cow_read,
+ &cb_interval, /* user data = */ NULL);
+ plugin_register_shutdown ("onewire", cow_shutdown);
+
+ return (0);
+} /* int cow_init */
+
void module_register (void)
{
plugin_register_init ("onewire", cow_init);
- plugin_register_read ("onewire", cow_read);
- plugin_register_shutdown ("onewire", cow_shutdown);
plugin_register_config ("onewire", cow_load_config,
config_keys, config_keys_num);
}