summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 30eeeee)
raw | patch | inline | side by side (parent: 30eeeee)
author | Florian Forster <octo@collectd.org> | |
Sat, 6 Jun 2015 20:33:34 +0000 (22:33 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Sat, 6 Jun 2015 20:33:34 +0000 (22:33 +0200) |
All plugins converted to "struct timespec", just so that
plugin_register_complex_read() would convert back to cdtime_t again. This patch
removed this crazyness; the new "determine automatically" value is zero (used
to be NULL).
plugin_register_complex_read() would convert back to cdtime_t again. This patch
removed this crazyness; the new "determine automatically" value is zero (used
to be NULL).
20 files changed:
src/apache.c | patch | blob | history | |
src/curl_json.c | patch | blob | history | |
src/curl_xml.c | patch | blob | history | |
src/daemon/plugin.c | patch | blob | history | |
src/daemon/plugin.h | patch | blob | history | |
src/dbi.c | patch | blob | history | |
src/java.c | patch | blob | history | |
src/memcached.c | patch | blob | history | |
src/modbus.c | patch | blob | history | |
src/mysql.c | patch | blob | history | |
src/netapp.c | patch | blob | history | |
src/onewire.c | patch | blob | history | |
src/openldap.c | patch | blob | history | |
src/postgresql.c | patch | blob | history | |
src/python.c | patch | blob | history | |
src/routeros.c | patch | blob | history | |
src/snmp.c | patch | blob | history | |
src/tail.c | patch | blob | history | |
src/tail_csv.c | patch | blob | history | |
src/varnish.c | patch | blob | history |
diff --git a/src/apache.c b/src/apache.c
index 0c6318e30f31fd02b75a6f7ecf19e1dea334ce8b..82a267b5ffbe91ac334d8280f6f7c8694bb0056d 100644 (file)
--- a/src/apache.c
+++ b/src/apache.c
status = plugin_register_complex_read (/* group = */ NULL,
/* name = */ callback_name,
/* callback = */ apache_read_host,
- /* interval = */ NULL,
+ /* interval = */ 0,
/* user_data = */ &ud);
}
diff --git a/src/curl_json.c b/src/curl_json.c
index 3a5a3ab87d7bd0a8320e88e5de5c4d08947d6222..937a237e06f7c5cba61eb6d0fc713919dc4c1ab9 100644 (file)
--- a/src/curl_json.c
+++ b/src/curl_json.c
{
user_data_t ud;
char *cb_name;
- struct timespec interval = { 0, 0 };
-
- CDTIME_T_TO_TIMESPEC (db->interval, &interval);
if (db->instance == NULL)
db->instance = strdup("default");
db->instance, db->url ? db->url : db->sock);
plugin_register_complex_read (/* group = */ NULL, cb_name, cj_read,
- /* interval = */ (db->interval > 0) ? &interval : NULL,
+ /* interval = */ db->interval,
&ud);
sfree (cb_name);
}
diff --git a/src/curl_xml.c b/src/curl_xml.c
index 689d5e1599c84bede8976dde892537f0e4d57a42..97b964bfbaa331cde2d991bbf8ea410771a8eeac 100644 (file)
--- a/src/curl_xml.c
+++ b/src/curl_xml.c
cb_name = ssnprintf_alloc ("curl_xml-%s-%s", db->instance, db->url);
plugin_register_complex_read (/* group = */ "curl_xml", cb_name, cx_read,
- /* interval = */ NULL, &ud);
+ /* interval = */ 0, &ud);
sfree (cb_name);
}
else
diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c
index 3d364458bfb4c3a3e0def36300e9a76d23cf88ee..b3cb97f6cee252dfd08d1f140b73b82ad16aeaa1 100644 (file)
--- a/src/daemon/plugin.c
+++ b/src/daemon/plugin.c
int plugin_register_complex_read (const char *group, const char *name,
plugin_read_cb callback,
- const struct timespec *interval,
+ cdtime_t interval,
user_data_t *user_data)
{
read_func_t *rf;
rf->rf_group[0] = '\0';
rf->rf_name = strdup (name);
rf->rf_type = RF_COMPLEX;
- if (interval != NULL)
- rf->rf_interval = TIMESPEC_TO_CDTIME_T (interval);
- else
- rf->rf_interval = plugin_get_interval ();
+ rf->rf_interval = (interval != 0) ? interval : plugin_get_interval ();
/* Set user data */
if (user_data == NULL)
diff --git a/src/daemon/plugin.h b/src/daemon/plugin.h
index 70a22326e09f7b3f492877711e6b5152e5e369c8..2e20da4c165fcbeadd82093e9c7495dc37b3474c 100644 (file)
--- a/src/daemon/plugin.h
+++ b/src/daemon/plugin.h
* "plugin_register_complex_read" returns an error (non-zero). */
int plugin_register_complex_read (const char *group, const char *name,
plugin_read_cb callback,
- const struct timespec *interval,
+ cdtime_t interval,
user_data_t *user_data);
int plugin_register_write (const char *name,
plugin_write_cb callback, user_data_t *user_data);
diff --git a/src/dbi.c b/src/dbi.c
index a7963ea223371f5d70a4ef63f2d0a3a6263db22a..d2b9a0eabec74ff75d7d867fc563489953f73863 100644 (file)
--- a/src/dbi.c
+++ b/src/dbi.c
plugin_register_complex_read (/* group = */ NULL,
/* name = */ name ? name : db->name,
/* callback = */ cdbi_read_database,
- /* interval = */ NULL,
+ /* interval = */ 0,
/* user_data = */ &ud);
free (name);
}
diff --git a/src/java.c b/src/java.c
index 2f1efbf16194f6b4b344e66bb2540927f8d736a4..56a39d40fe511247908acf10f795b1ac349ec6e6 100644 (file)
--- a/src/java.c
+++ b/src/java.c
ud.free_func = cjni_callback_info_destroy;
plugin_register_complex_read (/* group = */ NULL, cbi->name, cjni_read,
- /* interval = */ NULL, &ud);
+ /* interval = */ 0, &ud);
(*jvm_env)->DeleteLocalRef (jvm_env, o_read);
diff --git a/src/memcached.c b/src/memcached.c
index e2ccfee6ae72ae006ed7f539a2f526161aaba7bc..ab9de56fbba2516b5b37adccc3727eb1905761e6 100644 (file)
--- a/src/memcached.c
+++ b/src/memcached.c
status = plugin_register_complex_read (/* group = */ "memcached",
/* name = */ callback_name,
/* callback = */ memcached_read,
- /* interval = */ NULL,
+ /* interval = */ 0,
/* user_data = */ &ud);
return (status);
} /* int memcached_add_read_callback */
diff --git a/src/modbus.c b/src/modbus.c
index e24f2ec867eaff8704d5c4995b77dc2d695948c8..97840fd6cbf7bc3f6f8f0a8b1a6535bf4ca143fd 100644 (file)
--- a/src/modbus.c
+++ b/src/modbus.c
{
user_data_t ud;
char name[1024];
- struct timespec interval = { 0, 0 };
ud.data = host;
ud.free_func = host_free;
ssnprintf (name, sizeof (name), "modbus-%s", host->host);
- CDTIME_T_TO_TIMESPEC (host->interval, &interval);
-
plugin_register_complex_read (/* group = */ NULL, name,
/* callback = */ mb_read,
- /* interval = */ (host->interval > 0) ? &interval : NULL,
+ /* interval = */ host->interval,
&ud);
}
else
diff --git a/src/mysql.c b/src/mysql.c
index 00cba094977361f04420db6f87bb44245f90bc2d..bf77a2fff3c9545b4e6fe036f673cea3da64d7ba 100644 (file)
--- a/src/mysql.c
+++ b/src/mysql.c
plugin_register_complex_read (/* group = */ NULL, cb_name,
mysql_read,
- /* interval = */ NULL, &ud);
+ /* interval = */ 0, &ud);
}
else
{
diff --git a/src/netapp.c b/src/netapp.c
index f446d597de1f27610b0be1c7e2cfde8957509a79..020bfba192baffad8eb59661c464aaaf77bc585c 100644 (file)
--- a/src/netapp.c
+++ b/src/netapp.c
static int cna_register_host (host_config_t *host) /* {{{ */
{
char cb_name[256];
- struct timespec interval;
user_data_t ud;
if (host->vfiler)
else
ssnprintf (cb_name, sizeof (cb_name), "netapp-%s", host->name);
- CDTIME_T_TO_TIMESPEC (host->interval, &interval);
-
memset (&ud, 0, sizeof (ud));
ud.data = host;
ud.free_func = (void (*) (void *)) free_host_config;
plugin_register_complex_read (/* group = */ NULL, cb_name,
/* callback = */ cna_read,
- /* interval = */ (host->interval > 0) ? &interval : NULL,
+ /* interval = */ host->interval,
/* user data = */ &ud);
return (0);
diff --git a/src/onewire.c b/src/onewire.c
index 1383fc5803451437e6009b801ecbc0c6c16c798c..6cfea0ec1e7cc38c520cbb7f2ccebb5bb49b9437 100644 (file)
--- a/src/onewire.c
+++ b/src/onewire.c
static int cow_init (void)
{
int status;
- struct timespec cb_interval;
if (device_g == NULL)
{
return (1);
}
- CDTIME_T_TO_TIMESPEC (ow_interval, &cb_interval);
-
plugin_register_complex_read (/* group = */ NULL, "onewire", cow_read,
- (ow_interval != 0) ? &cb_interval : NULL,
- /* user data = */ NULL);
+ ow_interval, /* user data = */ NULL);
plugin_register_shutdown ("onewire", cow_shutdown);
return (0);
diff --git a/src/openldap.c b/src/openldap.c
index bca686e8aa9dd0ee2703ef748389e3224e64f497..bd989e40b3ffc707832a9126e24a478e61af1c0b 100644 (file)
--- a/src/openldap.c
+++ b/src/openldap.c
status = plugin_register_complex_read (/* group = */ NULL,
/* name = */ callback_name,
/* callback = */ cldap_read_host,
- /* interval = */ NULL,
+ /* interval = */ 0,
/* user_data = */ &ud);
}
diff --git a/src/postgresql.c b/src/postgresql.c
index 54c856d66464f68f9683a16c5c73cb630c180cbf..929b925c9924bec1b4dc09e7536f58c0aed2c972 100644 (file)
--- a/src/postgresql.c
+++ b/src/postgresql.c
c_psql_database_t *db;
char cb_name[DATA_MAX_NAME_LEN];
- struct timespec cb_interval = { 0, 0 };
user_data_t ud;
static _Bool have_flush = 0;
ssnprintf (cb_name, sizeof (cb_name), "postgresql-%s", db->instance);
if (db->queries_num > 0) {
- CDTIME_T_TO_TIMESPEC (db->interval, &cb_interval);
-
++db->ref_cnt;
plugin_register_complex_read ("postgresql", cb_name, c_psql_read,
- /* interval = */ (db->interval > 0) ? &cb_interval : NULL,
- &ud);
+ /* interval = */ db->interval, &ud);
}
if (db->writers_num > 0) {
++db->ref_cnt;
diff --git a/src/python.c b/src/python.c
index 8b378a299994105f9a7584e0e247d7a2710e2558..d2ef1648742e4050aa7b4d645a552d73f3b9a18e 100644 (file)
--- a/src/python.c
+++ b/src/python.c
@@ -656,7 +656,6 @@ static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwd
double interval = 0;
char *name = NULL;
PyObject *callback = NULL, *data = NULL;
- struct timespec ts;
static char *kwlist[] = {"callback", "interval", "data", "name", NULL};
if (PyArg_ParseTupleAndKeywords(args, kwds, "O|dOet", kwlist, &callback, &interval, &data, NULL, &name) == 0) return NULL;
@@ -678,10 +677,8 @@ static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwd
user_data = malloc(sizeof(*user_data));
user_data->free_func = cpy_destroy_user_data;
user_data->data = c;
- ts.tv_sec = interval;
- ts.tv_nsec = (interval - ts.tv_sec) * 1000000000;
plugin_register_complex_read(/* group = */ NULL, buf,
- cpy_read_callback, &ts, user_data);
+ cpy_read_callback, DOUBLE_TO_CDTIME_T (interval), user_data);
return cpy_string_to_unicode_or_bytes(buf);
}
diff --git a/src/routeros.c b/src/routeros.c
index 4ca9d5b2e77e6b3d059aee2e1d656b0d62cbf292..400ee42b64fcd294106f8681dfee3d3d9e77a0d1 100644 (file)
--- a/src/routeros.c
+++ b/src/routeros.c
user_data.free_func = (void *) cr_free_data;
if (status == 0)
status = plugin_register_complex_read (/* group = */ NULL, read_name,
- cr_read, /* interval = */ NULL, &user_data);
+ cr_read, /* interval = */ 0, &user_data);
if (status != 0)
cr_free_data (router_data);
diff --git a/src/snmp.c b/src/snmp.c
index cb2bb36d7bf7add534b4530af9697e879afa7a3d..51afea1b14e644b9a1b4c478a9883b65dbbe69ac 100644 (file)
--- a/src/snmp.c
+++ b/src/snmp.c
/* Registration stuff. */
char cb_name[DATA_MAX_NAME_LEN];
user_data_t cb_data;
- struct timespec cb_interval;
hd = (host_definition_t *) malloc (sizeof (host_definition_t));
if (hd == NULL)
cb_data.data = hd;
cb_data.free_func = csnmp_host_definition_destroy;
- CDTIME_T_TO_TIMESPEC (hd->interval, &cb_interval);
-
status = plugin_register_complex_read (/* group = */ NULL, cb_name,
- csnmp_read_host, /* interval = */ &cb_interval,
- /* user_data = */ &cb_data);
+ csnmp_read_host, hd->interval, /* user_data = */ &cb_data);
if (status != 0)
{
ERROR ("snmp plugin: Registering complex read function failed.");
diff --git a/src/tail.c b/src/tail.c
index ab063389a739fe64e561617f19e37158d6fcb869..9ff0d0bedf28eae98e736b3ea0d5f4de37055e49 100644 (file)
--- a/src/tail.c
+++ b/src/tail.c
static int ctail_init (void)
{
- struct timespec cb_interval;
char str[255];
user_data_t ud;
size_t i;
{
ud.data = (void *)tail_match_list[i];
ssnprintf(str, sizeof(str), "tail-%zu", i);
- CDTIME_T_TO_TIMESPEC (tail_match_list_intervals[i], &cb_interval);
- plugin_register_complex_read (NULL, str, ctail_read, &cb_interval, &ud);
+ plugin_register_complex_read (NULL, str, ctail_read, tail_match_list_intervals[i], &ud);
}
return (0);
diff --git a/src/tail_csv.c b/src/tail_csv.c
index a70b66589d287f4affef5003576e3583e1d55a8e..61eeee34c166a85923bb200e21a1a3aa3f0382b8 100644 (file)
--- a/src/tail_csv.c
+++ b/src/tail_csv.c
/* Registration variables */
char cb_name[DATA_MAX_NAME_LEN];
user_data_t cb_data;
- struct timespec cb_interval;
id = malloc(sizeof(*id));
if (id == NULL)
memset(&cb_data, 0, sizeof(cb_data));
cb_data.data = id;
cb_data.free_func = tcsv_instance_definition_destroy;
- CDTIME_T_TO_TIMESPEC(id->interval, &cb_interval);
- status = plugin_register_complex_read(NULL, cb_name, tcsv_read, &cb_interval, &cb_data);
+ status = plugin_register_complex_read(NULL, cb_name, tcsv_read, id->interval, &cb_data);
if (status != 0){
ERROR("tail_csv plugin: Registering complex read function failed.");
diff --git a/src/varnish.c b/src/varnish.c
index 8e6d95eefadb2c8cced71ceb87c22643457f648b..1d8fb557fc41bb39d528fa1ddc4c28b9e5b1846d 100644 (file)
--- a/src/varnish.c
+++ b/src/varnish.c
plugin_register_complex_read (/* group = */ "varnish",
/* name = */ "varnish/localhost",
/* callback = */ varnish_read,
- /* interval = */ NULL,
+ /* interval = */ 0,
/* user data = */ &ud);
return (0);