From: Sebastian Harl Date: Fri, 17 Jun 2011 08:53:24 +0000 (+0200) Subject: core: Changed internal API to allow for per-plugin intervals. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2139f51939cc70f5668ab68a16fefdb3d52bd663;p=collectd.git core: Changed internal API to allow for per-plugin intervals. This is the basic support for configuring custom intervals on a per-plugin basis. The following API changes have been introduced: - Each plugin's 'module_register()' function is now required to accept and respect an argument passing the custom interval (if configured). This is done by passing a pointer to a struct 'plugin_loaddata_t' which (currently) contains a single cdtime_t member storing the custom interval (0 if none has been configured). - A new plugin-global variable, 'plugin_interval', has been introduced. It is defined in 'plugin.h', and, thus, defined and available in all plugins. - A new macro, 'PLUGIN_INIT_INTERVAL', has been introduced to initialize 'plugin_interval' in 'module_register'. It requires the passed loaddata object as argument. In order for this mechanism to work, this macro has to be used in all plugins. - The macro 'VALUE_LIST_INIT' now requires the default interval as an argument. In most cases 'plugin_interval' should be used. - 'plugin_register_read' now requires a third argument specifying the interval. Usually, 'plugin_interval' should be passed. - The block now accepts an option 'Interval' to configure the custom interval. --- diff --git a/src/amqp.c b/src/amqp.c index adf4792b..1da9e5b2 100644 --- a/src/amqp.c +++ b/src/amqp.c @@ -474,7 +474,7 @@ static int camqp_read_body (camqp_config_t *conf, /* {{{ */ if (strcasecmp ("text/collectd", content_type) == 0) { - status = handle_putval (stderr, body); + status = handle_putval (stderr, body, /* default_interval = */ interval_g); if (status != 0) ERROR ("amqp plugin: handle_putval failed with status %i.", status); @@ -932,8 +932,10 @@ static int camqp_config (oconfig_item_t *ci) /* {{{ */ return (0); } /* }}} int camqp_config */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_complex_config ("amqp", camqp_config); plugin_register_shutdown ("amqp", camqp_shutdown); } /* void module_register */ diff --git a/src/apache.c b/src/apache.c index c31dd875..db73ea35 100644 --- a/src/apache.c +++ b/src/apache.c @@ -304,11 +304,14 @@ static int config_add (oconfig_item_t *ci) { user_data_t ud; char callback_name[3*DATA_MAX_NAME_LEN]; + struct timespec callback_interval; memset (&ud, 0, sizeof (ud)); ud.data = st; ud.free_func = (void *) apache_free; + CDTIME_T_TO_TIMESPEC (plugin_interval, &callback_interval); + memset (callback_name, 0, sizeof (callback_name)); ssnprintf (callback_name, sizeof (callback_name), "apache/%s/%s", @@ -318,7 +321,8 @@ static int config_add (oconfig_item_t *ci) status = plugin_register_complex_read (/* group = */ NULL, /* name = */ callback_name, /* callback = */ apache_read_host, - /* interval = */ NULL, + /* interval = */ (plugin_interval != 0) + ? &callback_interval : NULL, /* user_data = */ &ud); } @@ -456,7 +460,7 @@ static int init_host (apache_t *st) /* {{{ */ static void submit_value (const char *type, const char *type_instance, value_t value, apache_t *st) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); vl.values = &value; vl.values_len = 1; @@ -670,8 +674,9 @@ static int apache_read_host (user_data_t *user_data) /* {{{ */ return (0); } /* }}} int apache_read_host */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("apache", config); } /* void module_register */ diff --git a/src/apcups.c b/src/apcups.c index a0629d5f..0c2331b7 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -358,7 +358,7 @@ static int apcups_config (const char *key, const char *value) static void apc_submit_generic (char *type, char *type_inst, double value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -423,10 +423,12 @@ static int apcups_read (void) return (0); } /* apcups_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("apcups", apcups_config, config_keys, config_keys_num); - plugin_register_read ("apcups", apcups_read); + plugin_register_read ("apcups", apcups_read, plugin_interval); plugin_register_shutdown ("apcups", apcups_shutdown); } /* void module_register */ diff --git a/src/apple_sensors.c b/src/apple_sensors.c index bdba0ff8..7f4443b9 100644 --- a/src/apple_sensors.c +++ b/src/apple_sensors.c @@ -78,7 +78,7 @@ static void as_submit (const char *type, const char *type_instance, double val) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); DEBUG ("type = %s; type_instance = %s; val = %f;", type, type_instance, val); @@ -232,8 +232,10 @@ static int as_read (void) return (0); } /* int as_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_init ("apple_sensors", as_init); - plugin_register_read ("apple_sensors", as_read); + plugin_register_read ("apple_sensors", as_read, plugin_interval); } /* void module_register */ diff --git a/src/ascent.c b/src/ascent.c index 993e480c..bf6c7ca8 100644 --- a/src/ascent.c +++ b/src/ascent.c @@ -120,7 +120,7 @@ static int ascent_submit_gauge (const char *plugin_instance, /* {{{ */ const char *type, const char *type_instance, gauge_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -610,11 +610,13 @@ static int ascent_read (void) /* {{{ */ return (0); } /* }}} int ascent_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("ascent", ascent_config, config_keys, config_keys_num); plugin_register_init ("ascent", ascent_init); - plugin_register_read ("ascent", ascent_read); + plugin_register_read ("ascent", ascent_read, plugin_interval); } /* void module_register */ /* vim: set sw=2 sts=2 ts=8 et fdm=marker : */ diff --git a/src/battery.c b/src/battery.c index 4178d8b5..f36172db 100644 --- a/src/battery.c +++ b/src/battery.c @@ -96,7 +96,7 @@ static int battery_init (void) static void battery_submit (const char *plugin_instance, const char *type, double value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -530,8 +530,9 @@ static int battery_read (void) return (0); } -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_init ("battery", battery_init); - plugin_register_read ("battery", battery_read); + plugin_register_read ("battery", battery_read, plugin_interval); } /* void module_register */ diff --git a/src/bind.c b/src/bind.c index b640a596..363668b2 100644 --- a/src/bind.c +++ b/src/bind.c @@ -243,7 +243,7 @@ static void submit (time_t ts, const char *plugin_instance, /* {{{ */ const char *type, const char *type_instance, value_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0] = value; @@ -1431,11 +1431,12 @@ static int bind_shutdown (void) /* {{{ */ return (0); } /* }}} int bind_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("bind", bind_config); plugin_register_init ("bind", bind_init); - plugin_register_read ("bind", bind_read); + plugin_register_read ("bind", bind_read, plugin_interval); plugin_register_shutdown ("bind", bind_shutdown); } /* void module_register */ diff --git a/src/configfile.c b/src/configfile.c index 7c8347b1..d89bc275 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -244,6 +244,7 @@ static int dispatch_loadplugin (const oconfig_item_t *ci) int i; const char *name; unsigned int flags = 0; + plugin_loaddata_t loaddata; assert (strcasecmp (ci->key, "LoadPlugin") == 0); if (ci->values_num != 1) @@ -252,6 +253,7 @@ static int dispatch_loadplugin (const oconfig_item_t *ci) return (-1); name = ci->values[0].value.string; + memset (&loaddata, 0, sizeof (loaddata)); /* * XXX: Magic at work: @@ -271,6 +273,16 @@ static int dispatch_loadplugin (const oconfig_item_t *ci) for (i = 0; i < ci->children_num; ++i) { if (strcasecmp("Globals", ci->children[i].key) == 0) cf_util_get_flag (ci->children + i, &flags, PLUGIN_FLAGS_GLOBAL); + else if (strcasecmp ("Interval", ci->children[i].key) == 0) { + double interval = 0.0; + + if (cf_util_get_double (ci->children + i, &interval) != 0) { + /* cf_util_get_double will log an error */ + continue; + } + + loaddata.interval = DOUBLE_TO_CDTIME_T (interval); + } else { WARNING("Ignoring unknown LoadPlugin option \"%s\" " "for plugin \"%s\"", @@ -278,7 +290,7 @@ static int dispatch_loadplugin (const oconfig_item_t *ci) } } - return (plugin_load (name, (uint32_t) flags)); + return (plugin_load (name, (uint32_t) flags, &loaddata)); } /* int dispatch_value_loadplugin */ static int dispatch_value_plugin (const char *plugin, oconfig_item_t *ci) @@ -1015,6 +1027,23 @@ int cf_util_get_int (const oconfig_item_t *ci, int *ret_value) /* {{{ */ return (0); } /* }}} int cf_util_get_int */ +int cf_util_get_double (const oconfig_item_t *ci, double *ret_value) /* {{{ */ +{ + if ((ci == NULL) || (ret_value == NULL)) + return (EINVAL); + + if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER)) + { + ERROR ("cf_util_get_double: The %s option requires " + "exactly one numeric argument.", ci->key); + return (-1); + } + + *ret_value = ci->values[0].value.number; + + return (0); +} /* }}} int cf_util_get_double */ + int cf_util_get_boolean (const oconfig_item_t *ci, _Bool *ret_bool) /* {{{ */ { if ((ci == NULL) || (ret_bool == NULL)) diff --git a/src/configfile.h b/src/configfile.h index e63a0ea0..59ea5542 100644 --- a/src/configfile.h +++ b/src/configfile.h @@ -100,6 +100,9 @@ int cf_util_get_string_buffer (const oconfig_item_t *ci, char *buffer, /* Assures the config option is a number and returns it as an int. */ int cf_util_get_int (const oconfig_item_t *ci, int *ret_value); +/* Assures the config option is a number and returns it as a double. */ +int cf_util_get_double (const oconfig_item_t *ci, double *ret_value); + /* Assures the config option is a boolean and assignes it to `ret_bool'. * Otherwise, `ret_bool' is not changed and non-zero is returned. */ int cf_util_get_boolean (const oconfig_item_t *ci, _Bool *ret_bool); diff --git a/src/conntrack.c b/src/conntrack.c index e70ff5f1..8e5f7d56 100644 --- a/src/conntrack.c +++ b/src/conntrack.c @@ -34,7 +34,7 @@ static void conntrack_submit (double conntrack) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = conntrack; @@ -72,7 +72,8 @@ static int conntrack_read (void) return (0); } /* static int conntrack_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { - plugin_register_read ("conntrack", conntrack_read); + PLUGIN_INIT_INTERVAL (data); + plugin_register_read ("conntrack", conntrack_read, plugin_interval); } /* void module_register */ diff --git a/src/contextswitch.c b/src/contextswitch.c index c207318f..1cdce657 100644 --- a/src/contextswitch.c +++ b/src/contextswitch.c @@ -44,7 +44,7 @@ static void cs_submit (derive_t context_switches) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = (derive_t) context_switches; @@ -126,7 +126,8 @@ static int cs_read (void) return status; } -void module_register (void) +void module_register (plugin_loaddata_t *data) { - plugin_register_read ("contextswitch", cs_read); + PLUGIN_INIT_INTERVAL (data); + plugin_register_read ("contextswitch", cs_read, plugin_interval); } /* void module_register */ diff --git a/src/cpu.c b/src/cpu.c index 12071a2c..666fbad5 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -244,7 +244,7 @@ static int init (void) static void submit (int cpu_num, const char *type_instance, derive_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = value; @@ -601,8 +601,9 @@ static int cpu_read (void) return (0); } -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_init ("cpu", init); - plugin_register_read ("cpu", cpu_read); + plugin_register_read ("cpu", cpu_read, plugin_interval); } /* void module_register */ diff --git a/src/cpufreq.c b/src/cpufreq.c index b92b1d09..38d84ad7 100644 --- a/src/cpufreq.c +++ b/src/cpufreq.c @@ -61,7 +61,7 @@ static int cpufreq_init (void) static void cpufreq_submit (int cpu_num, double value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -130,8 +130,9 @@ static int cpufreq_read (void) return (0); } /* int cpufreq_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_init ("cpufreq", cpufreq_init); - plugin_register_read ("cpufreq", cpufreq_read); + plugin_register_read ("cpufreq", cpufreq_read, plugin_interval); } diff --git a/src/cpython.h b/src/cpython.h index 4b8aa721..4eb942de 100644 --- a/src/cpython.h +++ b/src/cpython.h @@ -161,6 +161,8 @@ static inline PyObject *cpy_string_to_unicode_or_bytes(const char *buf) { void cpy_log_exception(const char *context); +cdtime_t cpy_get_plugin_interval(void); + /* Python object declarations. */ typedef struct { diff --git a/src/csv.c b/src/csv.c index 02d62c1e..10b13ef8 100644 --- a/src/csv.c +++ b/src/csv.c @@ -365,8 +365,9 @@ static int csv_write (const data_set_t *ds, const value_list_t *vl, return (0); } /* int csv_write */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("csv", csv_config, config_keys, config_keys_num); plugin_register_write ("csv", csv_write, /* user_data = */ NULL); diff --git a/src/curl.c b/src/curl.c index 2160b980..16de8221 100644 --- a/src/curl.c +++ b/src/curl.c @@ -572,7 +572,7 @@ static void cc_submit (const web_page_t *wp, const web_match_t *wm, /* {{{ */ const cu_match_value_t *mv) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0] = mv->value; @@ -590,7 +590,7 @@ static void cc_submit (const web_page_t *wp, const web_match_t *wm, /* {{{ */ static void cc_submit_response_time (const web_page_t *wp, double seconds) /* {{{ */ { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = seconds; @@ -673,11 +673,13 @@ static int cc_shutdown (void) /* {{{ */ return (0); } /* }}} int cc_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_complex_config ("curl", cc_config); plugin_register_init ("curl", cc_init); - plugin_register_read ("curl", cc_read); + plugin_register_read ("curl", cc_read, plugin_interval); plugin_register_shutdown ("curl", cc_shutdown); } /* void module_register */ diff --git a/src/curl_json.c b/src/curl_json.c index 857e276b..3f77b7e1 100644 --- a/src/curl_json.c +++ b/src/curl_json.c @@ -621,6 +621,7 @@ static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */ { user_data_t ud; char cb_name[DATA_MAX_NAME_LEN]; + struct timespec cb_interval; if (db->instance == NULL) db->instance = strdup("default"); @@ -635,8 +636,14 @@ static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */ ssnprintf (cb_name, sizeof (cb_name), "curl_json-%s-%s", db->instance, db->url); - plugin_register_complex_read (/* group = */ NULL, cb_name, cj_read, - /* interval = */ NULL, &ud); + CDTIME_T_TO_TIMESPEC (plugin_interval, &cb_interval); + + plugin_register_complex_read (/* group = */ NULL, + /* name = */ cb_name, + /* callback = */ cj_read, + /* interval = */ (plugin_interval != 0) + ? &cb_interval : NULL, + /* user_data = */ &ud); } else { @@ -690,7 +697,7 @@ static int cj_config (oconfig_item_t *ci) /* {{{ */ static void cj_submit (cj_t *db, cj_key_t *key, value_t *value) /* {{{ */ { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); char *host; vl.values = value; @@ -807,8 +814,9 @@ static int cj_read (user_data_t *ud) /* {{{ */ return cj_curl_perform (db, db->curl); } /* }}} int cj_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("curl_json", cj_config); } /* void module_register */ diff --git a/src/curl_xml.c b/src/curl_xml.c index 61b5aded..56cf6f72 100644 --- a/src/curl_xml.c +++ b/src/curl_xml.c @@ -429,7 +429,7 @@ static int cx_handle_base_xpath (char *plugin_instance, /* {{{ */ xmlXPathObjectPtr base_node_obj = NULL; xmlNodeSetPtr base_nodes = NULL; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); base_node_obj = cx_evaluate_xpath (xpath_ctx, BAD_CAST base_xpath); if (base_node_obj == NULL) @@ -857,6 +857,7 @@ static int cx_config_add_url (oconfig_item_t *ci) /* {{{ */ { user_data_t ud; char cb_name[DATA_MAX_NAME_LEN]; + struct timespec cb_interval; if (db->instance == NULL) db->instance = strdup("default"); @@ -870,9 +871,14 @@ static int cx_config_add_url (oconfig_item_t *ci) /* {{{ */ ssnprintf (cb_name, sizeof (cb_name), "curl_xml-%s-%s", db->instance, db->url); + CDTIME_T_TO_TIMESPEC (plugin_interval, &cb_interval); - plugin_register_complex_read (/* group = */ NULL, cb_name, cx_read, - /* interval = */ NULL, &ud); + plugin_register_complex_read (/* group = */ NULL, + /* name = */ cb_name, + /* callback = */ cx_read, + /* interval = */ (plugin_interval != 0) + ? &cb_interval : NULL, + /* user_data = */ &ud); } else { @@ -923,8 +929,9 @@ static int cx_config (oconfig_item_t *ci) /* {{{ */ return (0); } /* }}} int cx_config */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("curl_xml", cx_config); } /* void module_register */ diff --git a/src/dbi.c b/src/dbi.c index caa41ef6..b55d39c0 100644 --- a/src/dbi.c +++ b/src/dbi.c @@ -566,7 +566,7 @@ static int cdbi_read_database_query (cdbi_database_t *db, /* {{{ */ udb_query_prepare_result (q, prep_area, hostname_g, /* plugin = */ "dbi", db->name, - column_names, column_num, /* interval = */ 0); + column_names, column_num, /* interval = */ plugin_interval); /* 0 = error; 1 = success; */ status = dbi_result_first_row (res); /* {{{ */ @@ -837,11 +837,12 @@ static int cdbi_shutdown (void) /* {{{ */ return (0); } /* }}} int cdbi_shutdown */ -void module_register (void) /* {{{ */ +void module_register (plugin_loaddata_t *data) /* {{{ */ { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("dbi", cdbi_config); plugin_register_init ("dbi", cdbi_init); - plugin_register_read ("dbi", cdbi_read); + plugin_register_read ("dbi", cdbi_read, plugin_interval); plugin_register_shutdown ("dbi", cdbi_shutdown); } /* }}} void module_register */ diff --git a/src/df.c b/src/df.c index 5391f50c..c5ae868f 100644 --- a/src/df.c +++ b/src/df.c @@ -142,7 +142,7 @@ static void df_submit_one (char *plugin_instance, gauge_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -293,10 +293,11 @@ static int df_read (void) return (0); } /* int df_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("df", df_config, config_keys, config_keys_num); plugin_register_init ("df", df_init); - plugin_register_read ("df", df_read); + plugin_register_read ("df", df_read, plugin_interval); } /* void module_register */ diff --git a/src/disk.c b/src/disk.c index fde0dcde..81ac3031 100644 --- a/src/disk.c +++ b/src/disk.c @@ -215,7 +215,7 @@ static void disk_submit (const char *plugin_instance, derive_t read, derive_t write) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); /* Both `ignorelist' and `plugin_instance' may be NULL. */ if (ignorelist_match (ignorelist, plugin_instance) != 0) @@ -753,10 +753,11 @@ static int disk_read (void) return (0); } /* int disk_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("disk", disk_config, config_keys, config_keys_num); plugin_register_init ("disk", disk_init); - plugin_register_read ("disk", disk_read); + plugin_register_read ("disk", disk_read, plugin_interval); } /* void module_register */ diff --git a/src/dns.c b/src/dns.c index 95797f54..9e868911 100644 --- a/src/dns.c +++ b/src/dns.c @@ -305,7 +305,7 @@ static void submit_derive (const char *type, const char *type_instance, derive_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = value; @@ -322,7 +322,7 @@ static void submit_derive (const char *type, const char *type_instance, static void submit_octets (derive_t queries, derive_t responses) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = queries; values[1].derive = responses; @@ -404,9 +404,10 @@ static int dns_read (void) return (0); } /* int dns_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("dns", dns_config, config_keys, config_keys_num); plugin_register_init ("dns", dns_init); - plugin_register_read ("dns", dns_read); + plugin_register_read ("dns", dns_read, plugin_interval); } /* void module_register */ diff --git a/src/email.c b/src/email.c index 8fc5509f..a7214fa5 100644 --- a/src/email.c +++ b/src/email.c @@ -650,7 +650,7 @@ static int email_shutdown (void) static void email_submit (const char *type, const char *type_instance, gauge_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -760,11 +760,12 @@ static int email_read (void) return (0); } /* int email_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("email", email_config, config_keys, config_keys_num); plugin_register_init ("email", email_init); - plugin_register_read ("email", email_read); + plugin_register_read ("email", email_read, plugin_interval); plugin_register_shutdown ("email", email_shutdown); } /* void module_register */ diff --git a/src/entropy.c b/src/entropy.c index d56be6dc..1a2c9375 100644 --- a/src/entropy.c +++ b/src/entropy.c @@ -32,7 +32,7 @@ static void entropy_submit (double entropy) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = entropy; @@ -70,7 +70,8 @@ static int entropy_read (void) return (0); } -void module_register (void) +void module_register (plugin_loaddata_t *data) { - plugin_register_read ("entropy", entropy_read); + PLUGIN_INIT_INTERVAL (data); + plugin_register_read ("entropy", entropy_read, plugin_interval); } /* void module_register */ diff --git a/src/exec.c b/src/exec.c index 4f6f9dfb..1da2bdd0 100644 --- a/src/exec.c +++ b/src/exec.c @@ -533,7 +533,7 @@ static int fork_child (program_list_t *pl, int *fd_in, int *fd_out, int *fd_err) static int parse_line (char *buffer) /* {{{ */ { if (strncasecmp ("PUTVAL", buffer, strlen ("PUTVAL")) == 0) - return (handle_putval (stdout, buffer)); + return (handle_putval (stdout, buffer, /* default_interval = */ plugin_interval)); else if (strncasecmp ("PUTNOTIF", buffer, strlen ("PUTNOTIF")) == 0) return (handle_putnotif (stdout, buffer)); else @@ -888,11 +888,13 @@ static int exec_shutdown (void) /* {{{ */ return (0); } /* int exec_shutdown }}} */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_complex_config ("exec", exec_config); plugin_register_init ("exec", exec_init); - plugin_register_read ("exec", exec_read); + plugin_register_read ("exec", exec_read, plugin_interval); plugin_register_notification ("exec", exec_notification, /* user_data = */ NULL); plugin_register_shutdown ("exec", exec_shutdown); diff --git a/src/filecount.c b/src/filecount.c index 47f99e91..c2f34ec3 100644 --- a/src/filecount.c +++ b/src/filecount.c @@ -61,7 +61,7 @@ static size_t directories_num = 0; static void fc_submit_dir (const fc_directory_conf_t *dir) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = (gauge_t) dir->files_num; @@ -565,11 +565,12 @@ static int fc_read (void) return (0); } /* int fc_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("filecount", fc_config); plugin_register_init ("filecount", fc_init); - plugin_register_read ("filecount", fc_read); + plugin_register_read ("filecount", fc_read, plugin_interval); } /* void module_register */ /* diff --git a/src/fscache.c b/src/fscache.c index 8fbd2713..c4597481 100644 --- a/src/fscache.c +++ b/src/fscache.c @@ -109,7 +109,7 @@ Ops pend=N Number of times async ops added to pending queues static void fscache_submit (const char *section, const char *name, value_t value) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); vl.values = &value; vl.values_len = 1; @@ -222,9 +222,10 @@ static int fscache_read (void){ return (0); } -void module_register (void) +void module_register (plugin_loaddata_t *data) { - plugin_register_read ("fscache", fscache_read); + PLUGIN_INIT_INTERVAL (data); + plugin_register_read ("fscache", fscache_read, plugin_interval); } /* void module_register */ /* vim: set sw=4 sts=4 et : */ diff --git a/src/gmond.c b/src/gmond.c index 3c746c48..4388f989 100644 --- a/src/gmond.c +++ b/src/gmond.c @@ -1114,8 +1114,9 @@ static int gmond_shutdown (void) /* {{{ */ return (0); } /* }}} int gmond_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("gmond", gmond_config); plugin_register_init ("gmond", gmond_init); plugin_register_shutdown ("gmond", gmond_shutdown); diff --git a/src/hddtemp.c b/src/hddtemp.c index 4428b75d..cf6d7cfe 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -231,7 +231,7 @@ static int hddtemp_config (const char *key, const char *value) static void hddtemp_submit (char *type_instance, double value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -301,9 +301,10 @@ static int hddtemp_read (void) /* module_register Register collectd plugin. */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("hddtemp", hddtemp_config, config_keys, config_keys_num); - plugin_register_read ("hddtemp", hddtemp_read); + plugin_register_read ("hddtemp", hddtemp_read, plugin_interval); } diff --git a/src/interface.c b/src/interface.c index c1e28e32..01dd3896 100644 --- a/src/interface.c +++ b/src/interface.c @@ -159,7 +159,7 @@ static void if_submit (const char *dev, const char *type, derive_t tx) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); if (ignorelist_match (ignorelist, dev) != 0) return; @@ -363,12 +363,14 @@ static int interface_read (void) return (0); } /* int interface_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("interface", interface_config, config_keys, config_keys_num); #if HAVE_LIBKSTAT plugin_register_init ("interface", interface_init); #endif - plugin_register_read ("interface", interface_read); + plugin_register_read ("interface", interface_read, plugin_interval); } /* void module_register */ diff --git a/src/ipmi.c b/src/ipmi.c index f341320d..3ec25ea6 100644 --- a/src/ipmi.c +++ b/src/ipmi.c @@ -119,7 +119,7 @@ static void sensor_read_handler (ipmi_sensor_t *sensor, void *user_data) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); c_ipmi_sensor_list_t *list_item = (c_ipmi_sensor_list_t *)user_data; @@ -715,12 +715,14 @@ static int c_ipmi_shutdown (void) return (0); } /* int c_ipmi_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("ipmi", c_ipmi_config, config_keys, config_keys_num); plugin_register_init ("ipmi", c_ipmi_init); - plugin_register_read ("ipmi", c_ipmi_read); + plugin_register_read ("ipmi", c_ipmi_read, plugin_interval); plugin_register_shutdown ("ipmi", c_ipmi_shutdown); } /* void module_register */ diff --git a/src/iptables.c b/src/iptables.c index 49454f05..e620d38a 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -246,7 +246,7 @@ static int submit6_match (const struct ip6t_entry_match *match, { int status; value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); /* Select the rules to collect */ if (chain->rule_type == RTYPE_NUM) @@ -307,7 +307,7 @@ static int submit_match (const struct ipt_entry_match *match, { int status; value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); /* Select the rules to collect */ if (chain->rule_type == RTYPE_NUM) @@ -511,11 +511,13 @@ static int iptables_shutdown (void) return (0); } /* int iptables_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("iptables", iptables_config, config_keys, config_keys_num); - plugin_register_read ("iptables", iptables_read); + plugin_register_read ("iptables", iptables_read, plugin_interval); plugin_register_shutdown ("iptables", iptables_shutdown); } /* void module_register */ diff --git a/src/ipvs.c b/src/ipvs.c index ab76f1eb..d7d43c0b 100644 --- a/src/ipvs.c +++ b/src/ipvs.c @@ -228,7 +228,7 @@ static int get_ti (struct ip_vs_dest_entry *de, char *ti, size_t size) static void cipvs_submit_connections (char *pi, char *ti, derive_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = value; @@ -250,7 +250,7 @@ static void cipvs_submit_if (char *pi, char *t, char *ti, derive_t rx, derive_t tx) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = rx; values[1].derive = tx; @@ -333,10 +333,11 @@ static int cipvs_shutdown (void) return 0; } /* cipvs_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_init ("ipvs", cipvs_init); - plugin_register_read ("ipvs", cipvs_read); + plugin_register_read ("ipvs", cipvs_read, plugin_interval); plugin_register_shutdown ("ipvs", cipvs_shutdown); return; } /* module_register */ diff --git a/src/irq.c b/src/irq.c index 7e738291..ae93cd29 100644 --- a/src/irq.c +++ b/src/irq.c @@ -109,7 +109,7 @@ static int check_ignore_irq (const char *irq) static void irq_submit (const char *irq_name, derive_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); if (check_ignore_irq (irq_name)) return; @@ -193,9 +193,11 @@ static int irq_read (void) return (0); } /* int irq_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("irq", irq_config, config_keys, config_keys_num); - plugin_register_read ("irq", irq_read); + plugin_register_read ("irq", irq_read, plugin_interval); } /* void module_register */ diff --git a/src/java.c b/src/java.c index b69ca946..5d5893c2 100644 --- a/src/java.c +++ b/src/java.c @@ -1325,7 +1325,7 @@ static int jtoc_notification (JNIEnv *jvm_env, notification_t *n, /* {{{ */ static jint JNICALL cjni_api_dispatch_values (JNIEnv *jvm_env, /* {{{ */ jobject this, jobject java_vl) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); int status; DEBUG ("cjni_api_dispatch_values: java_vl = %p;", (void *) java_vl); @@ -1410,6 +1410,8 @@ static jint JNICALL cjni_api_register_read (JNIEnv *jvm_env, /* {{{ */ user_data_t ud; cjni_callback_info_t *cbi; + struct timespec cb_interval; + cbi = cjni_callback_info_create (jvm_env, o_name, o_read, CB_TYPE_READ); if (cbi == NULL) return (-1); @@ -1420,8 +1422,13 @@ static jint JNICALL cjni_api_register_read (JNIEnv *jvm_env, /* {{{ */ ud.data = (void *) cbi; ud.free_func = cjni_callback_info_destroy; - plugin_register_complex_read (/* group = */ NULL, cbi->name, cjni_read, - /* interval = */ NULL, &ud); + CDTIME_T_TO_TIMESPEC (plugin_interval, &cb_interval); + + plugin_register_complex_read (/* group = */ NULL, + /* name = */ cbi->name, + /* callback = */ cjni_read, + /* interval = */ (plugin_interval != 0) ? &cb_interval : NULL, + /* user_data = */ &ud); (*jvm_env)->DeleteLocalRef (jvm_env, o_read); @@ -3101,11 +3108,12 @@ static int cjni_init (void) /* {{{ */ return (0); } /* }}} int cjni_init */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("java", cjni_config_callback); plugin_register_init ("java", cjni_init); plugin_register_shutdown ("java", cjni_shutdown); -} /* void module_register (void) */ +} /* void module_register (plugin_loaddata_t *data) */ /* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/src/libvirt.c b/src/libvirt.c index 774067cd..95b46143 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -182,7 +182,7 @@ cpu_submit (unsigned long long cpu_time, virDomainPtr dom, const char *type) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); init_value_list (&vl, dom); @@ -201,7 +201,7 @@ vcpu_submit (derive_t cpu_time, virDomainPtr dom, int vcpu_nr, const char *type) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); init_value_list (&vl, dom); @@ -220,7 +220,7 @@ submit_derive2 (const char *type, derive_t v0, derive_t v1, virDomainPtr dom, const char *devname) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); init_value_list (&vl, dom); @@ -822,13 +822,15 @@ lv_shutdown (void) } void -module_register (void) +module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("libvirt", lv_config, config_keys, NR_CONFIG_KEYS); plugin_register_init ("libvirt", lv_init); - plugin_register_read ("libvirt", lv_read); + plugin_register_read ("libvirt", lv_read, plugin_interval); plugin_register_shutdown ("libvirt", lv_shutdown); } diff --git a/src/load.c b/src/load.c index 0188da7e..e6a618d4 100644 --- a/src/load.c +++ b/src/load.c @@ -52,7 +52,7 @@ static void load_submit (gauge_t snum, gauge_t mnum, gauge_t lnum) { value_t values[3]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = snum; values[1].gauge = mnum; @@ -166,7 +166,8 @@ static int load_read (void) return (0); } -void module_register (void) +void module_register (plugin_loaddata_t *data) { - plugin_register_read ("load", load_read); + PLUGIN_INIT_INTERVAL (data); + plugin_register_read ("load", load_read, plugin_interval); } /* void module_register */ diff --git a/src/logfile.c b/src/logfile.c index 60fb5d92..40a5d7af 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -225,14 +225,16 @@ static int logfile_notification (const notification_t *n, return (0); } /* int logfile_notification */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("logfile", logfile_config, config_keys, config_keys_num); plugin_register_log ("logfile", logfile_log, /* user_data = */ NULL); plugin_register_notification ("logfile", logfile_notification, /* user_data = */ NULL); -} /* void module_register (void) */ +} /* void module_register (plugin_loaddata_t *data) */ /* vim: set sw=4 ts=4 tw=78 noexpandtab : */ diff --git a/src/lpar.c b/src/lpar.c index 4d534476..ff31d274 100644 --- a/src/lpar.c +++ b/src/lpar.c @@ -114,7 +114,7 @@ static int lpar_init (void) static void lpar_submit (const char *type_instance, double value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = (gauge_t)value; @@ -261,12 +261,14 @@ static int lpar_read (void) return (0); } /* int lpar_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("lpar", lpar_config, config_keys, config_keys_num); plugin_register_init ("lpar", lpar_init); - plugin_register_read ("lpar", lpar_read); + plugin_register_read ("lpar", lpar_read, plugin_interval); } /* void module_register */ /* vim: set sw=8 noet : */ diff --git a/src/madwifi.c b/src/madwifi.c index 13301fff..7af8b222 100644 --- a/src/madwifi.c +++ b/src/madwifi.c @@ -544,7 +544,7 @@ static int madwifi_config (const char *key, const char *value) static void submit (const char *dev, const char *type, const char *ti1, const char *ti2, value_t *val, int len) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); vl.values = val; vl.values_len = len; @@ -966,10 +966,11 @@ static int madwifi_read (void) return rv; } -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("madwifi", madwifi_config, config_keys, config_keys_num); - plugin_register_read ("madwifi", madwifi_read); + plugin_register_read ("madwifi", madwifi_read, plugin_interval); } diff --git a/src/match_empty_counter.c b/src/match_empty_counter.c index 1ab445a7..a06af564 100644 --- a/src/match_empty_counter.c +++ b/src/match_empty_counter.c @@ -102,10 +102,12 @@ static int mec_match (const data_set_t __attribute__((unused)) *ds, /* {{{ */ return (FC_MATCH_NO_MATCH); } /* }}} int mec_match */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { match_proc_t mproc; + PLUGIN_INIT_INTERVAL (data); + memset (&mproc, 0, sizeof (mproc)); mproc.create = mec_create; mproc.destroy = mec_destroy; diff --git a/src/match_hashed.c b/src/match_hashed.c index ee3101a2..6cb2c5a1 100644 --- a/src/match_hashed.c +++ b/src/match_hashed.c @@ -170,10 +170,12 @@ static int mh_match (const data_set_t __attribute__((unused)) *ds, /* {{{ */ return (FC_MATCH_NO_MATCH); } /* }}} int mh_match */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { match_proc_t mproc; + PLUGIN_INIT_INTERVAL (data); + memset (&mproc, 0, sizeof (mproc)); mproc.create = mh_create; mproc.destroy = mh_destroy; diff --git a/src/match_regex.c b/src/match_regex.c index 1defc180..44de1db3 100644 --- a/src/match_regex.c +++ b/src/match_regex.c @@ -298,10 +298,12 @@ static int mr_match (const data_set_t __attribute__((unused)) *ds, /* {{{ */ return (match_value); } /* }}} int mr_match */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { match_proc_t mproc; + PLUGIN_INIT_INTERVAL (data); + memset (&mproc, 0, sizeof (mproc)); mproc.create = mr_create; mproc.destroy = mr_destroy; diff --git a/src/match_timediff.c b/src/match_timediff.c index 2e274155..8e1980ff 100644 --- a/src/match_timediff.c +++ b/src/match_timediff.c @@ -139,10 +139,12 @@ static int mt_match (const data_set_t __attribute__((unused)) *ds, /* {{{ */ return (FC_MATCH_NO_MATCH); } /* }}} int mt_match */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { match_proc_t mproc; + PLUGIN_INIT_INTERVAL (data); + memset (&mproc, 0, sizeof (mproc)); mproc.create = mt_create; mproc.destroy = mt_destroy; diff --git a/src/match_value.c b/src/match_value.c index ae6282c4..aea01ebb 100644 --- a/src/match_value.c +++ b/src/match_value.c @@ -343,10 +343,12 @@ static int mv_match (const data_set_t *ds, const value_list_t *vl, /* {{{ */ return (status); } /* }}} int mv_match */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { match_proc_t mproc; + PLUGIN_INIT_INTERVAL (data); + memset (&mproc, 0, sizeof (mproc)); mproc.create = mv_create; mproc.destroy = mv_destroy; diff --git a/src/mbmon.c b/src/mbmon.c index 90226bbf..160ae5cb 100644 --- a/src/mbmon.c +++ b/src/mbmon.c @@ -223,7 +223,7 @@ static void mbmon_submit (const char *type, const char *type_instance, double value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -307,8 +307,10 @@ static int mbmon_read (void) /* module_register Register collectd plugin. */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("mbmon", mbmon_config, config_keys, config_keys_num); - plugin_register_read ("mbmon", mbmon_read); + plugin_register_read ("mbmon", mbmon_read, plugin_interval); } /* void module_register */ diff --git a/src/memcachec.c b/src/memcachec.c index 8f51e22f..e280e316 100644 --- a/src/memcachec.c +++ b/src/memcachec.c @@ -446,7 +446,7 @@ static void cmc_submit (const web_page_t *wp, const web_match_t *wm, /* {{{ */ const cu_match_value_t *mv) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0] = mv->value; @@ -525,11 +525,13 @@ static int cmc_shutdown (void) /* {{{ */ return (0); } /* }}} int cmc_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_complex_config ("memcachec", cmc_config); plugin_register_init ("memcachec", cmc_init); - plugin_register_read ("memcachec", cmc_read); + plugin_register_read ("memcachec", cmc_read, plugin_interval); plugin_register_shutdown ("memcachec", cmc_shutdown); } /* void module_register */ diff --git a/src/memcached.c b/src/memcached.c index ee3dbe12..6ae4843c 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -277,7 +277,7 @@ static void submit_derive (const char *type, const char *type_inst, derive_t value) /* {{{ */ { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = value; @@ -297,7 +297,7 @@ static void submit_derive2 (const char *type, const char *type_inst, derive_t value0, derive_t value1) /* {{{ */ { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = value0; values[1].derive = value1; @@ -318,7 +318,7 @@ static void submit_gauge (const char *type, const char *type_inst, gauge_t value) /* {{{ */ { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -338,7 +338,7 @@ static void submit_gauge2 (const char *type, const char *type_inst, gauge_t value0, gauge_t value1) /* {{{ */ { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value0; values[1].gauge = value1; @@ -514,10 +514,12 @@ static int memcached_read (void) /* {{{ */ } /* }}} */ -void module_register (void) /* {{{ */ +void module_register (plugin_loaddata_t *data) /* {{{ */ { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("memcached", memcached_config, config_keys, config_keys_num); - plugin_register_read ("memcached", memcached_read); + plugin_register_read ("memcached", memcached_read, plugin_interval); } /* }}} */ diff --git a/src/memory.c b/src/memory.c index b79a74b7..faf7092c 100644 --- a/src/memory.c +++ b/src/memory.c @@ -137,7 +137,7 @@ static int memory_init (void) static void memory_submit (const char *type_instance, gauge_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -397,8 +397,10 @@ static int memory_read (void) return (0); } -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_init ("memory", memory_init); - plugin_register_read ("memory", memory_read); + plugin_register_read ("memory", memory_read, plugin_interval); } /* void module_register */ diff --git a/src/modbus.c b/src/modbus.c index 19848b0b..5b3bc1cb 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -231,7 +231,7 @@ static int data_copy_by_name (mb_data_t **dst, mb_data_t *src, /* {{{ */ static int mb_submit (mb_host_t *host, mb_slave_t *slave, /* {{{ */ mb_data_t *data, value_t value) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); if ((host == NULL) || (slave == NULL) || (data == NULL)) return (EINVAL); @@ -932,6 +932,8 @@ static int mb_config_add_host (oconfig_item_t *ci) /* {{{ */ ssnprintf (name, sizeof (name), "modbus-%s", host->host); + if (host->interval <= 0) + host->interval = plugin_interval; CDTIME_T_TO_TIMESPEC (host->interval, &interval); plugin_register_complex_read (/* group = */ NULL, name, @@ -979,8 +981,9 @@ static int mb_shutdown (void) /* {{{ */ return (0); } /* }}} int mb_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("modbus", mb_config); plugin_register_shutdown ("modbus", mb_shutdown); } /* void module_register */ diff --git a/src/multimeter.c b/src/multimeter.c index 775eb57e..b54acfb3 100644 --- a/src/multimeter.c +++ b/src/multimeter.c @@ -194,7 +194,7 @@ static int multimeter_init (void) static void multimeter_submit (double value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -232,9 +232,11 @@ static int multimeter_shutdown (void) return (0); } -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_init ("multimeter", multimeter_init); - plugin_register_read ("multimeter", multimeter_read); + plugin_register_read ("multimeter", multimeter_read, plugin_interval); plugin_register_shutdown ("multimeter", multimeter_shutdown); } /* void module_register */ diff --git a/src/mysql.c b/src/mysql.c index 6b636787..104f072c 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -184,6 +184,7 @@ static int mysql_config_database (oconfig_item_t *ci) /* {{{ */ { user_data_t ud; char cb_name[DATA_MAX_NAME_LEN]; + struct timespec cb_interval; DEBUG ("mysql plugin: Registering new read callback: %s", (db->database != NULL) ? db->database : ""); @@ -198,9 +199,14 @@ static int mysql_config_database (oconfig_item_t *ci) /* {{{ */ else sstrncpy (cb_name, "mysql", sizeof (cb_name)); - plugin_register_complex_read (/* group = */ NULL, cb_name, - mysql_read, - /* interval = */ NULL, &ud); + CDTIME_T_TO_TIMESPEC (plugin_interval, &cb_interval); + + plugin_register_complex_read (/* group = */ NULL, + /* name = */ cb_name, + /* callback = */ mysql_read, + /* interval = */ (plugin_interval > 0) + ? &cb_interval : NULL, + /* user_data = */ &ud); } else { @@ -300,7 +306,7 @@ static void set_host (mysql_database_t *db, char *buf, size_t buflen) static void submit (const char *type, const char *type_instance, value_t *values, size_t values_len, mysql_database_t *db) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); vl.values = values; vl.values_len = values_len; @@ -706,7 +712,8 @@ static int mysql_read (user_data_t *ud) return (0); } /* int mysql_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("mysql", mysql_config); } /* void module_register */ diff --git a/src/netapp.c b/src/netapp.c index d9bd1ae5..53dea0cf 100644 --- a/src/netapp.c +++ b/src/netapp.c @@ -568,7 +568,7 @@ static int submit_values (const char *host, /* {{{ */ value_t *values, int values_len, cdtime_t timestamp, cdtime_t interval) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); vl.values = values; vl.values_len = values_len; @@ -2556,6 +2556,8 @@ static int cna_config (oconfig_item_t *ci) { /* {{{ */ ssnprintf (cb_name, sizeof (cb_name), "netapp-%s", host->name); + if (host->interval <= 0) + host->interval = plugin_interval; CDTIME_T_TO_TIMESPEC (host->interval, &interval); memset (&ud, 0, sizeof (ud)); @@ -2584,7 +2586,8 @@ static int cna_shutdown (void) /* {{{ */ return (0); } /* }}} int cna_shutdown */ -void module_register(void) { +void module_register(plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config("netapp", cna_config); plugin_register_init("netapp", cna_init); plugin_register_shutdown("netapp", cna_shutdown); diff --git a/src/netlink.c b/src/netlink.c index ef851d35..10c8dd1b 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -164,7 +164,7 @@ static void submit_one (const char *dev, const char *type, const char *type_instance, derive_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = value; @@ -186,7 +186,7 @@ static void submit_two (const char *dev, const char *type, derive_t rx, derive_t tx) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = rx; values[1].derive = tx; @@ -631,11 +631,12 @@ static int ir_shutdown (void) return (0); } /* int ir_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("netlink", ir_config, config_keys, config_keys_num); plugin_register_init ("netlink", ir_init); - plugin_register_read ("netlink", ir_read); + plugin_register_read ("netlink", ir_read, plugin_interval); plugin_register_shutdown ("netlink", ir_shutdown); } /* void module_register */ diff --git a/src/network.c b/src/network.c index 38534264..1d6708d5 100644 --- a/src/network.c +++ b/src/network.c @@ -1272,7 +1272,7 @@ static int parse_packet (sockent_t *se, /* {{{ */ { int status; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (/* default interval = */ 0); notification_t n; #if HAVE_LIBGCRYPT @@ -3208,7 +3208,7 @@ static int network_stats_read (void) /* {{{ */ derive_t copy_values_sent; derive_t copy_values_not_sent; derive_t copy_receive_list_length; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); value_t values[2]; copy_octets_rx = stats_octets_rx; @@ -3291,7 +3291,7 @@ static int network_init (void) #endif if (network_config_stats != 0) - plugin_register_read ("network", network_stats_read); + plugin_register_read ("network", network_stats_read, plugin_interval); plugin_register_shutdown ("network", network_shutdown); @@ -3382,8 +3382,9 @@ static int network_flush (__attribute__((unused)) cdtime_t timeout, return (0); } /* int network_flush */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("network", network_config); plugin_register_init ("network", network_init); plugin_register_flush ("network", network_flush, diff --git a/src/nfs.c b/src/nfs.c index f3c636ec..a42a8858 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -182,7 +182,7 @@ static void nfs_procedures_submit (const char *plugin_instance, unsigned long long *val, const char **names, int len) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); int i; vl.values = values; @@ -356,7 +356,8 @@ static int nfs_read (void) return (0); } -void module_register (void) +void module_register (plugin_loaddata_t *data) { - plugin_register_read ("nfs", nfs_read); + PLUGIN_INIT_INTERVAL (data); + plugin_register_read ("nfs", nfs_read, plugin_interval); } /* void module_register */ diff --git a/src/nginx.c b/src/nginx.c index 3e162bac..15370db7 100644 --- a/src/nginx.c +++ b/src/nginx.c @@ -174,7 +174,7 @@ static int init (void) static void submit (char *type, char *inst, long long value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); if (strcmp (type, "nginx_connections") == 0) values[0].gauge = value; @@ -274,11 +274,12 @@ static int nginx_read (void) return (0); } /* int nginx_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("nginx", config, config_keys, config_keys_num); plugin_register_init ("nginx", init); - plugin_register_read ("nginx", nginx_read); + plugin_register_read ("nginx", nginx_read, plugin_interval); } /* void module_register */ /* diff --git a/src/notify_desktop.c b/src/notify_desktop.c index 3f3c6dfc..aa2c216e 100644 --- a/src/notify_desktop.c +++ b/src/notify_desktop.c @@ -161,8 +161,9 @@ static int c_notify_init (void) return 0; } /* c_notify_init */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("notify_desktop", c_notify_config); plugin_register_init ("notify_desktop", c_notify_init); return; diff --git a/src/notify_email.c b/src/notify_email.c index cd216ca2..1c3890d1 100644 --- a/src/notify_email.c +++ b/src/notify_email.c @@ -313,14 +313,16 @@ static int notify_email_notification (const notification_t *n, return (0); } /* int notify_email_notification */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_init ("notify_email", notify_email_init); plugin_register_shutdown ("notify_email", notify_email_shutdown); plugin_register_config ("notify_email", notify_email_config, config_keys, config_keys_num); plugin_register_notification ("notify_email", notify_email_notification, /* user_data = */ NULL); -} /* void module_register (void) */ +} /* void module_register (plugin_loaddata_t *data) */ /* vim: set sw=2 sts=2 ts=8 et : */ diff --git a/src/ntpd.c b/src/ntpd.c index 8bbf74d7..ce074039 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -294,7 +294,7 @@ static int ntpd_config (const char *key, const char *value) static void ntpd_submit (char *type, char *type_inst, double value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -957,9 +957,10 @@ static int ntpd_read (void) return (0); } /* int ntpd_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("ntpd", ntpd_config, config_keys, config_keys_num); - plugin_register_read ("ntpd", ntpd_read); + plugin_register_read ("ntpd", ntpd_read, plugin_interval); } /* void module_register */ diff --git a/src/nut.c b/src/nut.c index edc48c61..8ca07781 100644 --- a/src/nut.c +++ b/src/nut.c @@ -117,7 +117,7 @@ static void nut_submit (nut_ups_t *ups, const char *type, const char *type_instance, gauge_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -282,10 +282,11 @@ static int nut_shutdown (void) return (0); } /* int nut_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("nut", nut_config, config_keys, config_keys_num); - plugin_register_read ("nut", nut_read); + plugin_register_read ("nut", nut_read, plugin_interval); plugin_register_shutdown ("nut", nut_shutdown); } /* void module_register */ diff --git a/src/olsrd.c b/src/olsrd.c index be422ab6..5cc20f9c 100644 --- a/src/olsrd.c +++ b/src/olsrd.c @@ -216,7 +216,7 @@ static void olsrd_submit (const char *plugin_instance, /* {{{ */ const char *type, const char *type_instance, gauge_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -698,11 +698,12 @@ static int olsrd_shutdown (void) /* {{{ */ return (0); } /* }}} int olsrd_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("olsrd", olsrd_config, config_keys, config_keys_num); - plugin_register_read ("olsrd", olsrd_read); + plugin_register_read ("olsrd", olsrd_read, plugin_interval); plugin_register_shutdown ("olsrd", olsrd_shutdown); } /* void module_register */ diff --git a/src/onewire.c b/src/onewire.c index 09a6bf09..8d4e600b 100644 --- a/src/onewire.c +++ b/src/onewire.c @@ -125,7 +125,7 @@ static int cow_read_values (const char *path, const char *name, const ow_family_features_t *family_info) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); int success = 0; size_t i; @@ -306,6 +306,8 @@ static int cow_init (void) return (1); } + if (ow_interval <= 0) + ow_interval = plugin_interval; CDTIME_T_TO_TIMESPEC (ow_interval, &cb_interval); plugin_register_complex_read (/* group = */ NULL, "onewire", cow_read, @@ -316,8 +318,9 @@ static int cow_init (void) return (0); } /* int cow_init */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_init ("onewire", cow_init); plugin_register_config ("onewire", cow_load_config, config_keys, config_keys_num); diff --git a/src/openvpn.c b/src/openvpn.c index 9ce23b4f..2b374bcf 100644 --- a/src/openvpn.c +++ b/src/openvpn.c @@ -96,7 +96,7 @@ static int openvpn_strsplit (char *string, char **fields, size_t size) static void numusers_submit (char *pinst, char *tinst, gauge_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -117,7 +117,7 @@ static void numusers_submit (char *pinst, char *tinst, gauge_t value) static void iostats_submit (char *pinst, char *tinst, derive_t rx, derive_t tx) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = rx; values[1].derive = tx; @@ -147,7 +147,7 @@ static void compression_submit (char *pinst, char *tinst, derive_t uncompressed, derive_t compressed) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = uncompressed; values[1].derive = compressed; @@ -713,14 +713,16 @@ static int openvpn_init (void) return (-1); } - plugin_register_read ("openvpn", openvpn_read); + plugin_register_read ("openvpn", openvpn_read, plugin_interval); plugin_register_shutdown ("openvpn", openvpn_shutdown); return (0); } /* int openvpn_init */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("openvpn", openvpn_config, config_keys, config_keys_num); plugin_register_init ("openvpn", openvpn_init); diff --git a/src/oracle.c b/src/oracle.c index 03567494..e648fb77 100644 --- a/src/oracle.c +++ b/src/oracle.c @@ -586,7 +586,7 @@ static int o_read_database_query (o_database_t *db, /* {{{ */ status = udb_query_prepare_result (q, prep_area, hostname_g, /* plugin = */ "oracle", db->name, column_names, column_num, - /* interval = */ 0); + /* interval = */ plugin_interval); if (status != 0) { ERROR ("oracle plugin: o_read_database_query (%s, %s): " @@ -745,11 +745,13 @@ static int o_shutdown (void) /* {{{ */ return (0); } /* }}} int o_shutdown */ -void module_register (void) /* {{{ */ +void module_register (plugin_loaddata_t *data) /* {{{ */ { + PLUGIN_INIT_INTERVAL (data); + plugin_register_complex_config ("oracle", o_config); plugin_register_init ("oracle", o_init); - plugin_register_read ("oracle", o_read); + plugin_register_read ("oracle", o_read, plugin_interval); plugin_register_shutdown ("oracle", o_shutdown); } /* }}} void module_register */ diff --git a/src/perl.c b/src/perl.c index f8a48227..e6965e06 100644 --- a/src/perl.c +++ b/src/perl.c @@ -931,7 +931,7 @@ static int pplugin_unregister_data_set (char *name) */ static int pplugin_dispatch_values (pTHX_ HV *values) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); int ret = 0; @@ -953,7 +953,7 @@ static int pplugin_dispatch_values (pTHX_ HV *values) static int pplugin_write (pTHX_ const char *plugin, AV *data_set, HV *values) { data_set_t ds; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); int ret; @@ -2258,7 +2258,7 @@ static int init_pi (int argc, char **argv) /* user_data = */ NULL); plugin_register_init ("perl", perl_init); - plugin_register_read ("perl", perl_read); + plugin_register_read ("perl", perl_read, plugin_interval); plugin_register_write ("perl", perl_write, /* user_data = */ NULL); plugin_register_flush ("perl", perl_flush, /* user_data = */ NULL); @@ -2499,8 +2499,10 @@ static int perl_config (oconfig_item_t *ci) return status; } /* static int perl_config (oconfig_item_t *) */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + perl_argc = 4; perl_argv = (char **)smalloc ((perl_argc + 1) * sizeof (char *)); @@ -2513,7 +2515,7 @@ void module_register (void) plugin_register_complex_config ("perl", perl_config); return; -} /* void module_register (void) */ +} /* void module_register (plugin_loaddata_t *data) */ /* vim: set sw=4 ts=4 tw=78 noexpandtab : */ diff --git a/src/pinba.c b/src/pinba.c index a6fd06fe..8c4da1a8 100644 --- a/src/pinba.c +++ b/src/pinba.c @@ -602,7 +602,7 @@ static int pinba_config_view (const oconfig_item_t *ci) /* {{{ */ return (status); } /* }}} int pinba_config_view */ -static int plugin_config (oconfig_item_t *ci) /* {{{ */ +static int cpinba_config (oconfig_item_t *ci) /* {{{ */ { int i; @@ -629,7 +629,7 @@ static int plugin_config (oconfig_item_t *ci) /* {{{ */ return (0); } /* }}} int pinba_config */ -static int plugin_init (void) /* {{{ */ +static int cpinba_init (void) /* {{{ */ { int status; @@ -661,7 +661,7 @@ static int plugin_init (void) /* {{{ */ return (0); } /* }}} */ -static int plugin_shutdown (void) /* {{{ */ +static int cpinba_shutdown (void) /* {{{ */ { if (collector_thread_running) { @@ -683,12 +683,12 @@ static int plugin_shutdown (void) /* {{{ */ } /* if (collector_thread_running) */ return (0); -} /* }}} int plugin_shutdown */ +} /* }}} int cpinba_shutdown */ -static int plugin_submit (const pinba_statnode_t *res) /* {{{ */ +static int cpinba_submit (const pinba_statnode_t *res) /* {{{ */ { value_t value; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); vl.values = &value; vl.values_len = 1; @@ -724,27 +724,29 @@ static int plugin_submit (const pinba_statnode_t *res) /* {{{ */ plugin_dispatch_values (&vl); return (0); -} /* }}} int plugin_submit */ +} /* }}} int cpinba_submit */ -static int plugin_read (void) /* {{{ */ +static int cpinba_read (void) /* {{{ */ { unsigned int i=0; pinba_statnode_t data; while ((i = service_statnode_collect (&data, i)) != 0) { - plugin_submit (&data); + cpinba_submit (&data); } return 0; -} /* }}} int plugin_read */ +} /* }}} int cpinba_read */ -void module_register (void) /* {{{ */ +void module_register (plugin_loaddata_t *data) /* {{{ */ { - plugin_register_complex_config ("pinba", plugin_config); - plugin_register_init ("pinba", plugin_init); - plugin_register_read ("pinba", plugin_read); - plugin_register_shutdown ("pinba", plugin_shutdown); + PLUGIN_INIT_INTERVAL (data); + + plugin_register_complex_config ("pinba", cpinba_config); + plugin_register_init ("pinba", cpinba_init); + plugin_register_read ("pinba", cpinba_read, plugin_interval); + plugin_register_shutdown ("pinba", cpinba_shutdown); } /* }}} void module_register */ /* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/src/ping.c b/src/ping.c index b536f429..7adbfe13 100644 --- a/src/ping.c +++ b/src/ping.c @@ -542,7 +542,7 @@ static void submit (const char *host, const char *type, /* {{{ */ gauge_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -667,12 +667,14 @@ static int ping_shutdown (void) /* {{{ */ return (0); } /* }}} int ping_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("ping", ping_config, config_keys, config_keys_num); plugin_register_init ("ping", ping_init); - plugin_register_read ("ping", ping_read); + plugin_register_read ("ping", ping_read, plugin_interval); plugin_register_shutdown ("ping", ping_shutdown); } /* void module_register */ diff --git a/src/plugin.c b/src/plugin.c index a749d1e0..e87f6e26 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -275,10 +275,10 @@ static int plugin_unregister (llist_t *list, const char *name) /* {{{ */ * object, but it will bitch about a shared object not having a * ``module_register'' symbol.. */ -static int plugin_load_file (char *file, uint32_t flags) +static int plugin_load_file (char *file, uint32_t flags, plugin_loaddata_t *data) { lt_dlhandle dlh; - void (*reg_handle) (void); + void (*reg_handle) (plugin_loaddata_t *); lt_dlinit (); lt_dlerror (); /* clear errors */ @@ -321,7 +321,8 @@ static int plugin_load_file (char *file, uint32_t flags) return (1); } - if ((reg_handle = (void (*) (void)) lt_dlsym (dlh, "module_register")) == NULL) + reg_handle = (void (*) (plugin_loaddata_t *)) lt_dlsym (dlh, "module_register"); + if (reg_handle == NULL) { WARNING ("Couldn't find symbol \"module_register\" in \"%s\": %s\n", file, lt_dlerror ()); @@ -329,7 +330,7 @@ static int plugin_load_file (char *file, uint32_t flags) return (-1); } - (*reg_handle) (); + (*reg_handle) (data); return (0); } @@ -580,7 +581,7 @@ void plugin_set_dir (const char *dir) } #define BUFSIZE 512 -int plugin_load (const char *type, uint32_t flags) +int plugin_load (const char *type, uint32_t flags, plugin_loaddata_t *data) { DIR *dh; const char *dir; @@ -642,7 +643,7 @@ int plugin_load (const char *type, uint32_t flags) continue; } - if (plugin_load_file (filename, flags) == 0) + if (plugin_load_file (filename, flags, data) == 0) { /* success */ ret = 0; @@ -774,7 +775,7 @@ static int plugin_insert_read (read_func_t *rf) } /* int plugin_insert_read */ int plugin_register_read (const char *name, - int (*callback) (void)) + int (*callback) (void), cdtime_t interval) { read_func_t *rf; int status; @@ -793,8 +794,7 @@ int plugin_register_read (const char *name, rf->rf_group[0] = '\0'; sstrncpy (rf->rf_name, name, sizeof (rf->rf_name)); rf->rf_type = RF_SIMPLE; - rf->rf_interval.tv_sec = 0; - rf->rf_interval.tv_nsec = 0; + CDTIME_T_TO_TIMESPEC (interval, &rf->rf_interval); rf->rf_effective_interval = rf->rf_interval; status = plugin_insert_read (rf); diff --git a/src/plugin.h b/src/plugin.h index e8804728..490770a5 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -68,6 +68,13 @@ /* * Public data types */ +struct plugin_loaddata_s +{ + cdtime_t interval; +}; +typedef struct plugin_loaddata_s plugin_loaddata_t; +static cdtime_t __attribute__((unused)) plugin_interval = 0; + typedef unsigned long long counter_t; typedef double gauge_t; typedef int64_t derive_t; @@ -97,7 +104,7 @@ struct value_list_s }; typedef struct value_list_s value_list_t; -#define VALUE_LIST_INIT { NULL, 0, 0, interval_g, "localhost", "", "", "", "", NULL } +#define VALUE_LIST_INIT(interval) { NULL, 0, 0, (interval), "localhost", "", "", "", "", NULL } #define VALUE_LIST_STATIC { NULL, 0, 0, 0, "localhost", "", "", "", "", NULL } struct data_source_s @@ -208,6 +215,7 @@ void plugin_set_dir (const char *dir); * ARGUMENTS * `name' Name of the plugin to load. * `flags' Hints on how to handle this plugin. + * `data' Additional arguments to pass to the plugin. * * RETURN VALUE * Returns zero upon success, a value greater than zero if no plugin was found @@ -216,7 +224,23 @@ void plugin_set_dir (const char *dir); * NOTES * No attempt is made to re-load an already loaded module. */ -int plugin_load (const char *name, uint32_t flags); +int plugin_load (const char *name, uint32_t flags, plugin_loaddata_t *data); + +/* + * NAME + * PLUGIN_INIT_INTERVAL + * + * DESCRIPTION + * Initialize the plugin specific interval settings. + * + * ARGUMENTS + * `data' Data provided by LoadPlugin, like custom interval settings. + */ +#define PLUGIN_INIT_INTERVAL(data) \ + do { \ + if ((data)->interval != 0) \ + plugin_interval = (data)->interval; \ + } while (0) void plugin_init_all (void); void plugin_read_all (void); @@ -268,7 +292,7 @@ int plugin_register_complex_config (const char *type, int plugin_register_init (const char *name, plugin_init_cb callback); int plugin_register_read (const char *name, - int (*callback) (void)); + int (*callback) (void), cdtime_t interval); /* "user_data" will be freed automatically, unless * "plugin_register_complex_read" returns an error (non-zero). */ int plugin_register_complex_read (const char *group, const char *name, diff --git a/src/postgresql.c b/src/postgresql.c index a8812e21..0bb56534 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -680,6 +680,8 @@ static int c_psql_config_database (oconfig_item_t *ci) ssnprintf (cb_name, sizeof (cb_name), "postgresql-%s", db->database); + if (db->interval <= 0) + db->interval = plugin_interval; CDTIME_T_TO_TIMESPEC (db->interval, &cb_interval); plugin_register_complex_read ("postgresql", cb_name, c_psql_read, @@ -724,8 +726,9 @@ static int c_psql_config (oconfig_item_t *ci) return 0; } /* c_psql_config */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("postgresql", c_psql_config); plugin_register_shutdown ("postgresql", c_psql_shutdown); } /* module_register */ diff --git a/src/powerdns.c b/src/powerdns.c index a1b23555..ae74b437 100644 --- a/src/powerdns.c +++ b/src/powerdns.c @@ -246,7 +246,7 @@ static char *local_sockpath = NULL; static void submit (const char *plugin_instance, /* {{{ */ const char *pdns_type, const char *value) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); value_t values[1]; const char *type = NULL; @@ -979,10 +979,11 @@ static int powerdns_shutdown (void) return (0); } /* static int powerdns_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("powerdns", powerdns_config); - plugin_register_read ("powerdns", powerdns_read); + plugin_register_read ("powerdns", powerdns_read, plugin_interval); plugin_register_shutdown ("powerdns", powerdns_shutdown ); } /* void module_register */ diff --git a/src/processes.c b/src/processes.c index 8f4eb88f..b77f2aee 100644 --- a/src/processes.c +++ b/src/processes.c @@ -623,7 +623,7 @@ static int ps_init (void) static void ps_submit_state (const char *state, double value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -642,7 +642,7 @@ static void ps_submit_state (const char *state, double value) static void ps_submit_proc_list (procstat_t *ps) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); vl.values = values; vl.values_len = 2; @@ -1139,7 +1139,7 @@ static unsigned long read_fork_rate () static void ps_submit_fork_rate (unsigned long value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = (derive_t) value; @@ -1837,9 +1837,11 @@ static int ps_read (void) return (0); } /* int ps_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_complex_config ("processes", ps_config); plugin_register_init ("processes", ps_init); - plugin_register_read ("processes", ps_read); + plugin_register_read ("processes", ps_read, plugin_interval); } /* void module_register */ diff --git a/src/protocols.c b/src/protocols.c index 0dfba210..e87534e8 100644 --- a/src/protocols.c +++ b/src/protocols.c @@ -50,7 +50,7 @@ static void submit (const char *protocol_name, const char *str_key, const char *str_value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); int status; status = parse_value (str_value, values, DS_TYPE_DERIVE); @@ -232,11 +232,12 @@ static int protocols_config (const char *key, const char *value) return (0); } /* int protocols_config */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("protocols", protocols_config, config_keys, config_keys_num); - plugin_register_read ("protocols", protocols_read); + plugin_register_read ("protocols", protocols_read, plugin_interval); } /* void module_register */ /* vim: set sw=2 sts=2 et : */ diff --git a/src/python.c b/src/python.c index ee673883..3e678f3a 100644 --- a/src/python.c +++ b/src/python.c @@ -315,6 +315,10 @@ void cpy_log_exception(const char *context) { PyErr_Clear(); } +cdtime_t cpy_get_plugin_interval(void) { + return plugin_interval; +} + static int cpy_read_callback(user_data_t *data) { cpy_callback_t *c = data->data; PyObject *ret; @@ -627,8 +631,14 @@ 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; + if (interval > 0.0) { + ts.tv_sec = interval; + ts.tv_nsec = (interval - ts.tv_sec) * 1000000000; + } + else { + CDTIME_T_TO_TIMESPEC (plugin_interval, &ts); + } + plugin_register_complex_read(/* group = */ NULL, buf, cpy_read_callback, &ts, user_data); return cpy_string_to_unicode_or_bytes(buf); @@ -1142,7 +1152,8 @@ static int cpy_config(oconfig_item_t *ci) { return 0; } -void module_register(void) { +void module_register(plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config("python", cpy_config); plugin_register_init("python", cpy_init); plugin_register_shutdown("python", cpy_shutdown); diff --git a/src/pyvalues.c b/src/pyvalues.c index 36a717e9..23732173 100644 --- a/src/pyvalues.c +++ b/src/pyvalues.c @@ -482,7 +482,7 @@ static PyObject *Values_dispatch(Values *self, PyObject *args, PyObject *kwds) { const data_set_t *ds; int size; value_t *value; - value_list_t value_list = VALUE_LIST_INIT; + value_list_t value_list = VALUE_LIST_INIT(/* default interval = */ 0); PyObject *values = self->values, *meta = self->meta; double time = self->data.time, interval = self->interval; const char *host = self->data.host; @@ -558,7 +558,10 @@ static PyObject *Values_dispatch(Values *self, PyObject *args, PyObject *kwds) { value_list.meta = cpy_build_meta(meta); value_list.values_len = size; value_list.time = DOUBLE_TO_CDTIME_T(time); - value_list.interval = DOUBLE_TO_CDTIME_T(interval); + if (interval > 0.0) + value_list.interval = DOUBLE_TO_CDTIME_T(interval); + else + value_list.interval = cpy_get_plugin_interval(); sstrncpy(value_list.host, host, sizeof(value_list.host)); sstrncpy(value_list.plugin, plugin, sizeof(value_list.plugin)); sstrncpy(value_list.plugin_instance, plugin_instance, sizeof(value_list.plugin_instance)); @@ -584,7 +587,7 @@ static PyObject *Values_write(Values *self, PyObject *args, PyObject *kwds) { const data_set_t *ds; int size; value_t *value; - value_list_t value_list = VALUE_LIST_INIT; + value_list_t value_list = VALUE_LIST_INIT(/* default interval = */ 0); PyObject *values = self->values, *meta = self->meta; double time = self->data.time, interval = self->interval; const char *host = self->data.host; @@ -656,7 +659,10 @@ static PyObject *Values_write(Values *self, PyObject *args, PyObject *kwds) { value_list.values = value; value_list.values_len = size; value_list.time = DOUBLE_TO_CDTIME_T(time); - value_list.interval = DOUBLE_TO_CDTIME_T(interval); + if (interval > 0.0) + value_list.interval = DOUBLE_TO_CDTIME_T(interval); + else + value_list.interval = cpy_get_plugin_interval(); sstrncpy(value_list.host, host, sizeof(value_list.host)); sstrncpy(value_list.plugin, plugin, sizeof(value_list.plugin)); sstrncpy(value_list.plugin_instance, plugin_instance, sizeof(value_list.plugin_instance)); diff --git a/src/redis.c b/src/redis.c index b694e09d..5032b771 100644 --- a/src/redis.c +++ b/src/redis.c @@ -176,7 +176,7 @@ static void redis_submit_g (char *plugin_instance, gauge_t value) /* {{{ */ { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -201,7 +201,7 @@ static void redis_submit_d (char *plugin_instance, derive_t value) /* {{{ */ { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = value; @@ -298,11 +298,13 @@ static int redis_read (void) /* {{{ */ } /* }}} */ -void module_register (void) /* {{{ */ +void module_register (plugin_loaddata_t *data) /* {{{ */ { + PLUGIN_INIT_INTERVAL (data); + plugin_register_complex_config ("redis", redis_config); plugin_register_init ("redis", redis_init); - plugin_register_read ("redis", redis_read); + plugin_register_read ("redis", redis_read, plugin_interval); /* TODO: plugin_register_write: one redis list per value id with * X elements */ } diff --git a/src/routeros.c b/src/routeros.c index d61ffe98..c35a0483 100644 --- a/src/routeros.c +++ b/src/routeros.c @@ -47,7 +47,7 @@ static void cr_submit_io (cr_data_t *rd, const char *type, /* {{{ */ const char *type_instance, derive_t rx, derive_t tx) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = rx; values[1].derive = tx; @@ -100,7 +100,7 @@ static void cr_submit_gauge (cr_data_t *rd, const char *type, /* {{{ */ const char *type_instance, gauge_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -119,7 +119,7 @@ static void cr_submit_counter (cr_data_t *rd, const char *type, /* {{{ */ const char *type_instance, derive_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = value; @@ -319,6 +319,7 @@ static int cr_config_router (oconfig_item_t *ci) /* {{{ */ { cr_data_t *router_data; char read_name[128]; + struct timespec read_interval; user_data_t user_data; int status; int i; @@ -405,11 +406,15 @@ static int cr_config_router (oconfig_item_t *ci) /* {{{ */ } ssnprintf (read_name, sizeof (read_name), "routeros/%s", router_data->node); + CDTIME_T_TO_TIMESPEC (plugin_interval, &read_interval); user_data.data = router_data; 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); + status = plugin_register_complex_read (/* group = */ NULL, + /* name = */ read_name, + /* callback = */ cr_read, + /* interval = */ (plugin_interval > 0) ? &read_interval : NULL, + /* user_data = */ &user_data); if (status != 0) cr_free_data (router_data); @@ -436,8 +441,9 @@ static int cr_config (oconfig_item_t *ci) return (0); } /* }}} int cr_config */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("routeros", cr_config); } /* void module_register */ diff --git a/src/rrdcached.c b/src/rrdcached.c index 11c1c6a7..8a937d46 100644 --- a/src/rrdcached.c +++ b/src/rrdcached.c @@ -257,7 +257,7 @@ static int rc_read (void) rrdc_stats_t *ptr; value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); if (daemon_address == NULL) return (-1); @@ -355,7 +355,7 @@ static int rc_read (void) static int rc_init (void) { if (config_collect_stats != 0) - plugin_register_read ("rrdcached", rc_read); + plugin_register_read ("rrdcached", rc_read, plugin_interval); return (0); } /* int rc_init */ @@ -482,8 +482,10 @@ static int rc_shutdown (void) return (0); } /* int rc_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_complex_config ("rrdcached", rc_config); plugin_register_init ("rrdcached", rc_init); plugin_register_shutdown ("rrdcached", rc_shutdown); diff --git a/src/rrdtool.c b/src/rrdtool.c index 56a82d03..88a939e9 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -1215,8 +1215,10 @@ static int rrd_init (void) return (0); } /* int rrd_init */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("rrdtool", rrd_config, config_keys, config_keys_num); plugin_register_init ("rrdtool", rrd_init); diff --git a/src/sensors.c b/src/sensors.c index 8391346b..596d7df0 100644 --- a/src/sensors.c +++ b/src/sensors.c @@ -477,7 +477,7 @@ static void sensors_submit (const char *plugin_instance, int status; value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); status = ssnprintf (match_key, sizeof (match_key), "%s/%s-%s", plugin_instance, type, type_instance); @@ -581,10 +581,12 @@ static int sensors_read (void) return (0); } /* int sensors_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("sensors", sensors_config, config_keys, config_keys_num); - plugin_register_read ("sensors", sensors_read); + plugin_register_read ("sensors", sensors_read, plugin_interval); plugin_register_shutdown ("sensors", sensors_shutdown); } /* void module_register */ diff --git a/src/serial.c b/src/serial.c index 9bd885db..7069a21d 100644 --- a/src/serial.c +++ b/src/serial.c @@ -33,7 +33,7 @@ static void serial_submit (const char *type_instance, derive_t rx, derive_t tx) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = rx; values[1].derive = tx; @@ -119,7 +119,8 @@ static int serial_read (void) return (0); } /* int serial_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { - plugin_register_read ("serial", serial_read); + PLUGIN_INIT_INTERVAL (data); + plugin_register_read ("serial", serial_read, plugin_interval); } /* void module_register */ diff --git a/src/snmp.c b/src/snmp.c index 7a848511..9e3143b7 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -634,6 +634,8 @@ static int csnmp_config_add_host (oconfig_item_t *ci) cb_data.data = hd; cb_data.free_func = csnmp_host_definition_destroy; + if (hd->interval <= 0) + hd->interval = plugin_interval; CDTIME_T_TO_TIMESPEC (hd->interval, &cb_interval); status = plugin_register_complex_read (/* group = */ NULL, cb_name, @@ -1025,7 +1027,7 @@ static int csnmp_dispatch_table (host_definition_t *host, data_definition_t *dat csnmp_table_values_t **value_table) { const data_set_t *ds; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); csnmp_list_instances_t *instance_list_ptr; csnmp_table_values_t **value_table_ptr; @@ -1406,7 +1408,7 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data) struct variable_list *vb; const data_set_t *ds; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); int status; int i; @@ -1598,8 +1600,10 @@ static int csnmp_shutdown (void) return (0); } /* int csnmp_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_complex_config ("snmp", csnmp_config); plugin_register_init ("snmp", csnmp_init); plugin_register_shutdown ("snmp", csnmp_shutdown); diff --git a/src/swap.c b/src/swap.c index 397969ef..f9165a2a 100644 --- a/src/swap.c +++ b/src/swap.c @@ -179,7 +179,7 @@ static void swap_submit (const char *plugin_instance, /* {{{ */ const char *type, const char *type_instance, value_t value) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); assert (type != NULL); @@ -771,13 +771,15 @@ static int swap_read (void) /* {{{ */ } /* }}} int swap_read */ #endif /* HAVE_PERFSTAT */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + #if SWAP_HAVE_CONFIG plugin_register_config ("swap", swap_config, config_keys, config_keys_num); #endif plugin_register_init ("swap", swap_init); - plugin_register_read ("swap", swap_read); + plugin_register_read ("swap", swap_read, plugin_interval); } /* void module_register */ /* vim: set fdm=marker : */ diff --git a/src/syslog.c b/src/syslog.c index ace9dc6f..f9f42045 100644 --- a/src/syslog.c +++ b/src/syslog.c @@ -84,11 +84,13 @@ static int sl_shutdown (void) return (0); } -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + openlog ("collectd", LOG_CONS | LOG_PID, LOG_DAEMON); plugin_register_config ("syslog", sl_config, config_keys, config_keys_num); plugin_register_log ("syslog", sl_log, /* user_data = */ NULL); plugin_register_shutdown ("syslog", sl_shutdown); -} /* void module_register(void) */ +} /* void module_register(plugin_loaddata_t *data) */ diff --git a/src/table.c b/src/table.c index 9641c759..123b6968 100644 --- a/src/table.c +++ b/src/table.c @@ -369,7 +369,7 @@ static int tbl_finish (tbl_t *tbl) static int tbl_result_dispatch (tbl_t *tbl, tbl_result_t *res, char **fields, size_t fields_num) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); value_t values[res->values_num]; size_t i; @@ -546,13 +546,14 @@ static int tbl_init (void) if (0 == tables_num) return 0; - plugin_register_read ("table", tbl_read); + plugin_register_read ("table", tbl_read, plugin_interval); plugin_register_shutdown ("table", tbl_shutdown); return 0; } /* tbl_init */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("table", tbl_config); plugin_register_init ("table", tbl_init); } /* module_register */ diff --git a/src/tail.c b/src/tail.c index 25cbcd4c..96523486 100644 --- a/src/tail.c +++ b/src/tail.c @@ -207,7 +207,8 @@ static int ctail_config_add_match (cu_tail_match_t *tm, if (status == 0) { status = tail_match_add_match_simple (tm, cm.regex, cm.excluderegex, - cm.flags, "tail", plugin_instance, cm.type, cm.type_instance); + cm.flags, "tail", plugin_instance, cm.type, cm.type_instance, + plugin_interval); if (status != 0) { @@ -368,11 +369,13 @@ static int ctail_shutdown (void) return (0); } /* int ctail_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_complex_config ("tail", ctail_config); plugin_register_init ("tail", ctail_init); - plugin_register_read ("tail", ctail_read); + plugin_register_read ("tail", ctail_read, plugin_interval); plugin_register_shutdown ("tail", ctail_shutdown); } /* void module_register */ diff --git a/src/tape.c b/src/tape.c index a8e7dc45..9063d3ce 100644 --- a/src/tape.c +++ b/src/tape.c @@ -61,7 +61,7 @@ static void tape_submit (const char *plugin_instance, derive_t read, derive_t write) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = read; values[1].derive = write; @@ -126,8 +126,9 @@ static int tape_read (void) return (0); } -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_init ("tape", tape_init); - plugin_register_read ("tape", tape_read); + plugin_register_read ("tape", tape_read, plugin_interval); } diff --git a/src/target_notification.c b/src/target_notification.c index cb68048b..df756907 100644 --- a/src/target_notification.c +++ b/src/target_notification.c @@ -270,10 +270,12 @@ static int tn_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ return (FC_TARGET_CONTINUE); } /* }}} int tn_invoke */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { target_proc_t tproc; + PLUGIN_INIT_INTERVAL (data); + memset (&tproc, 0, sizeof (tproc)); tproc.create = tn_create; tproc.destroy = tn_destroy; diff --git a/src/target_replace.c b/src/target_replace.c index 9a9affb4..e0722fff 100644 --- a/src/target_replace.c +++ b/src/target_replace.c @@ -341,10 +341,12 @@ static int tr_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ return (FC_TARGET_CONTINUE); } /* }}} int tr_invoke */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { target_proc_t tproc; + PLUGIN_INIT_INTERVAL (data); + memset (&tproc, 0, sizeof (tproc)); tproc.create = tr_create; tproc.destroy = tr_destroy; diff --git a/src/target_scale.c b/src/target_scale.c index af224f10..ccd1d085 100644 --- a/src/target_scale.c +++ b/src/target_scale.c @@ -409,10 +409,12 @@ static int ts_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ return (FC_TARGET_CONTINUE); } /* }}} int ts_invoke */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { target_proc_t tproc; + PLUGIN_INIT_INTERVAL (data); + memset (&tproc, 0, sizeof (tproc)); tproc.create = ts_create; tproc.destroy = ts_destroy; diff --git a/src/target_set.c b/src/target_set.c index 8a014c3c..099f1096 100644 --- a/src/target_set.c +++ b/src/target_set.c @@ -214,10 +214,12 @@ static int ts_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ return (FC_TARGET_CONTINUE); } /* }}} int ts_invoke */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { target_proc_t tproc; + PLUGIN_INIT_INTERVAL (data); + memset (&tproc, 0, sizeof (tproc)); tproc.create = ts_create; tproc.destroy = ts_destroy; diff --git a/src/target_v5upgrade.c b/src/target_v5upgrade.c index 25f4637d..f4e87603 100644 --- a/src/target_v5upgrade.c +++ b/src/target_v5upgrade.c @@ -457,10 +457,12 @@ static int v5_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ return (FC_TARGET_CONTINUE); } /* }}} int v5_invoke */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { target_proc_t tproc; + PLUGIN_INIT_INTERVAL (data); + memset (&tproc, 0, sizeof (tproc)); tproc.create = v5_create; tproc.destroy = v5_destroy; diff --git a/src/tcpconns.c b/src/tcpconns.c index 6a7e32d7..d4c14a22 100644 --- a/src/tcpconns.c +++ b/src/tcpconns.c @@ -262,7 +262,7 @@ static port_entry_t *port_list_head = NULL; static void conn_submit_port_entry (port_entry_t *pe) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); int i; vl.values = values; @@ -815,8 +815,10 @@ static int conn_read (void) } #endif /* KERNEL_AIX */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("tcpconns", conn_config, config_keys, config_keys_num); #if KERNEL_LINUX @@ -828,7 +830,7 @@ void module_register (void) #elif KERNEL_AIX /* no initialization */ #endif - plugin_register_read ("tcpconns", conn_read); + plugin_register_read ("tcpconns", conn_read, plugin_interval); } /* void module_register */ /* diff --git a/src/teamspeak2.c b/src/teamspeak2.c index 2552ad30..48a81ce9 100644 --- a/src/teamspeak2.c +++ b/src/teamspeak2.c @@ -123,7 +123,7 @@ static void tss2_submit_gauge (const char *plugin_instance, * Submits a gauge value to the collectd daemon */ value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -152,7 +152,7 @@ static void tss2_submit_io (const char *plugin_instance, const char *type, * Submits the io rx/tx tuple to the collectd daemon */ value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = rx; values[1].derive = tx; @@ -837,14 +837,15 @@ static int tss2_shutdown(void) return (0); } /* int tss2_shutdown */ -void module_register(void) +void module_register(plugin_loaddata_t *data) { /* * Mandatory module_register function */ + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("teamspeak2", tss2_config, config_keys, config_keys_num); - plugin_register_read ("teamspeak2", tss2_read); + plugin_register_read ("teamspeak2", tss2_read, plugin_interval); plugin_register_shutdown ("teamspeak2", tss2_shutdown); } /* void module_register */ diff --git a/src/ted.c b/src/ted.c index bf519bbe..6ecef3ef 100644 --- a/src/ted.c +++ b/src/ted.c @@ -267,7 +267,7 @@ static int ted_open_device (void) static void ted_submit (char *type, double value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -348,11 +348,13 @@ static int ted_shutdown (void) return (0); } /* int ted_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("ted", ted_config, config_keys, config_keys_num); - plugin_register_read ("ted", ted_read); + plugin_register_read ("ted", ted_read, plugin_interval); plugin_register_shutdown ("ted", ted_shutdown); } /* void module_register */ diff --git a/src/thermal.c b/src/thermal.c index 0ad0d90a..f029a3bd 100644 --- a/src/thermal.c +++ b/src/thermal.c @@ -49,7 +49,7 @@ enum dev_type { static void thermal_submit (const char *plugin_instance, enum dev_type dt, gauge_t value) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); value_t v; v.gauge = value; @@ -232,9 +232,9 @@ static int thermal_init (void) int ret = -1; if (!force_procfs && access (dirname_sysfs, R_OK | X_OK) == 0) { - ret = plugin_register_read ("thermal", thermal_sysfs_read); + ret = plugin_register_read ("thermal", thermal_sysfs_read, plugin_interval); } else if (access (dirname_procfs, R_OK | X_OK) == 0) { - ret = plugin_register_read ("thermal", thermal_procfs_read); + ret = plugin_register_read ("thermal", thermal_procfs_read, plugin_interval); } return ret; @@ -247,8 +247,9 @@ static int thermal_shutdown (void) return 0; } -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("thermal", thermal_config, config_keys, STATIC_ARRAY_SIZE(config_keys)); plugin_register_init ("thermal", thermal_init); diff --git a/src/threshold.c b/src/threshold.c index 342d08ac..5b00b7a9 100644 --- a/src/threshold.c +++ b/src/threshold.c @@ -1018,8 +1018,9 @@ int ut_config (oconfig_item_t *ci) return (status); } /* }}} int um_config */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("threshold", ut_config); } diff --git a/src/tokyotyrant.c b/src/tokyotyrant.c index 678a341c..6cb358e8 100644 --- a/src/tokyotyrant.c +++ b/src/tokyotyrant.c @@ -89,7 +89,7 @@ static void printerr() static void tt_submit (gauge_t val, const char* type) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = val; @@ -169,11 +169,13 @@ static int tt_shutdown(void) return(0); } -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config("tokyotyrant", tt_config, config_keys, config_keys_num); - plugin_register_read("tokyotyrant", tt_read); + plugin_register_read("tokyotyrant", tt_read, plugin_interval); plugin_register_shutdown("tokyotyrant", tt_shutdown); } diff --git a/src/unixsock.c b/src/unixsock.c index d729477b..f62ba3dc 100644 --- a/src/unixsock.c +++ b/src/unixsock.c @@ -276,7 +276,7 @@ static void *us_handle_client (void *arg) } else if (strcasecmp (fields[0], "putval") == 0) { - handle_putval (fhout, buffer); + handle_putval (fhout, buffer, /* default_interval = */ interval_g); } else if (strcasecmp (fields[0], "listval") == 0) { @@ -465,12 +465,14 @@ static int us_shutdown (void) return (0); } /* int us_shutdown */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("unixsock", us_config, config_keys, config_keys_num); plugin_register_init ("unixsock", us_init); plugin_register_shutdown ("unixsock", us_shutdown); -} /* void module_register (void) */ +} /* void module_register (plugin_loaddata_t *data) */ /* vim: set sw=4 ts=4 sts=4 tw=78 : */ diff --git a/src/uptime.c b/src/uptime.c index d2ba9633..6a147aff 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -54,7 +54,7 @@ extern kstat_ctl_t *kc; static void uptime_submit (gauge_t uptime) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = uptime; @@ -223,8 +223,9 @@ static int uptime_read (void) return (0); } -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_init ("uptime", uptime_init); - plugin_register_read ("uptime", uptime_read); + plugin_register_read ("uptime", uptime_read, plugin_interval); } /* void module_register */ diff --git a/src/users.c b/src/users.c index 1e337540..0753b07b 100644 --- a/src/users.c +++ b/src/users.c @@ -48,7 +48,7 @@ static void users_submit (gauge_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -116,7 +116,8 @@ static int users_read (void) return (0); } /* int users_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { - plugin_register_read ("users", users_read); -} /* void module_register(void) */ + PLUGIN_INIT_INTERVAL (data); + plugin_register_read ("users", users_read, plugin_interval); +} /* void module_register(plugin_loaddata_t *data) */ diff --git a/src/utils_cache.c b/src/utils_cache.c index dd5bcb59..27d22534 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -305,7 +305,7 @@ int uc_check_timeout (void) * plugin calls the cache interface. */ for (i = 0; i < keys_len; i++) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (/* default interval = */ 0); vl.values = NULL; vl.values_len = 0; diff --git a/src/utils_cmd_putval.c b/src/utils_cmd_putval.c index dd43337e..89c55287 100644 --- a/src/utils_cmd_putval.c +++ b/src/utils_cmd_putval.c @@ -73,7 +73,7 @@ static int set_option (value_list_t *vl, const char *key, const char *value) return (0); } /* int parse_option */ -int handle_putval (FILE *fh, char *buffer) +int handle_putval (FILE *fh, char *buffer, cdtime_t default_interval) { char *command; char *identifier; @@ -88,7 +88,7 @@ int handle_putval (FILE *fh, char *buffer) char *identifier_copy; const data_set_t *ds; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (default_interval); DEBUG ("utils_cmd_putval: handle_putval (fh = %p, buffer = %s);", (void *) fh, buffer); diff --git a/src/utils_cmd_putval.h b/src/utils_cmd_putval.h index 9c92fd31..9aa2ef27 100644 --- a/src/utils_cmd_putval.h +++ b/src/utils_cmd_putval.h @@ -26,7 +26,7 @@ #include "plugin.h" -int handle_putval (FILE *fh, char *buffer); +int handle_putval (FILE *fh, char *buffer, cdtime_t default_interval); int create_putval (char *ret, size_t ret_len, const data_set_t *ds, const value_list_t *vl); diff --git a/src/utils_db_query.c b/src/utils_db_query.c index dcac8076..047eb82d 100644 --- a/src/utils_db_query.c +++ b/src/utils_db_query.c @@ -186,7 +186,7 @@ static int udb_result_submit (udb_result_t *r, /* {{{ */ udb_result_preparation_area_t *r_area, const udb_query_t const *q, udb_query_preparation_area_t *q_area) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (/* default_interval = */ 0); size_t i; assert (r != NULL); diff --git a/src/utils_tail_match.c b/src/utils_tail_match.c index 8ae2208c..69902ddb 100644 --- a/src/utils_tail_match.c +++ b/src/utils_tail_match.c @@ -37,6 +37,7 @@ struct cu_tail_match_simple_s char plugin_instance[DATA_MAX_NAME_LEN]; char type[DATA_MAX_NAME_LEN]; char type_instance[DATA_MAX_NAME_LEN]; + cdtime_t interval; }; typedef struct cu_tail_match_simple_s cu_tail_match_simple_t; @@ -65,7 +66,7 @@ static int simple_submit_match (cu_match_t *match, void *user_data) { cu_tail_match_simple_t *data = (cu_tail_match_simple_t *) user_data; cu_match_value_t *match_value; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (/* default_interval = */ 0); value_t values[1]; match_value = (cu_match_value_t *) match_get_user_data (match); @@ -87,6 +88,7 @@ static int simple_submit_match (cu_match_t *match, void *user_data) sstrncpy (vl.type, data->type, sizeof (vl.type)); sstrncpy (vl.type_instance, data->type_instance, sizeof (vl.type_instance)); + vl.interval = data->interval; plugin_dispatch_values (&vl); @@ -193,7 +195,8 @@ int tail_match_add_match (cu_tail_match_t *obj, cu_match_t *match, int tail_match_add_match_simple (cu_tail_match_t *obj, const char *regex, const char *excluderegex, int ds_type, const char *plugin, const char *plugin_instance, - const char *type, const char *type_instance) + const char *type, const char *type_instance, + cdtime_t interval) { cu_match_t *match; cu_tail_match_simple_t *user_data; @@ -221,6 +224,8 @@ int tail_match_add_match_simple (cu_tail_match_t *obj, sstrncpy (user_data->type_instance, type_instance, sizeof (user_data->type_instance)); + user_data->interval = interval; + status = tail_match_add_match (obj, match, simple_submit_match, user_data, free); diff --git a/src/utils_tail_match.h b/src/utils_tail_match.h index 76597457..4b6e7943 100644 --- a/src/utils_tail_match.h +++ b/src/utils_tail_match.h @@ -105,7 +105,8 @@ int tail_match_add_match (cu_tail_match_t *obj, cu_match_t *match, int tail_match_add_match_simple (cu_tail_match_t *obj, const char *regex, const char *excluderegex, int ds_type, const char *plugin, const char *plugin_instance, - const char *type, const char *type_instance); + const char *type, const char *type_instance, + cdtime_t interval); /* * NAME diff --git a/src/uuid.c b/src/uuid.c index cf23f5b3..929b901c 100644 --- a/src/uuid.c +++ b/src/uuid.c @@ -266,8 +266,9 @@ uuid_init (void) return 0; } -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_config ("uuid", uuid_config, config_keys, NR_CONFIG_KEYS); plugin_register_init ("uuid", uuid_init); diff --git a/src/varnish.c b/src/varnish.c index 37fd4bb3..2693b7c4 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -158,7 +158,7 @@ static _Bool have_instance = 0; static int varnish_submit (const char *plugin_instance, /* {{{ */ const char *category, const char *type, const char *type_instance, value_t value) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); vl.values = &value; vl.values_len = 1; @@ -434,6 +434,7 @@ static int varnish_config_apply_default (user_config_t *conf) /* {{{ */ static int varnish_init (void) /* {{{ */ { user_config_t *conf; + struct timespec cb_interval; user_data_t ud; if (have_instance) @@ -452,10 +453,12 @@ static int varnish_init (void) /* {{{ */ ud.data = conf; ud.free_func = varnish_config_free; + CDTIME_T_TO_TIMESPEC (plugin_interval, &cb_interval); + plugin_register_complex_read (/* group = */ "varnish", /* name = */ "varnish/localhost", /* callback = */ varnish_read, - /* interval = */ NULL, + /* interval = */ (plugin_interval > 0) ? &cb_interval : NULL, /* user data = */ &ud); return (0); @@ -466,6 +469,7 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ user_config_t *conf; user_data_t ud; char callback_name[DATA_MAX_NAME_LEN]; + struct timespec cb_interval; int i; conf = malloc (sizeof (*conf)); @@ -559,13 +563,15 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ ssnprintf (callback_name, sizeof (callback_name), "varnish/%s", (conf->instance == NULL) ? "localhost" : conf->instance); + CDTIME_T_TO_TIMESPEC (plugin_interval, &cb_interval); + ud.data = conf; ud.free_func = varnish_config_free; plugin_register_complex_read (/* group = */ "varnish", /* name = */ callback_name, /* callback = */ varnish_read, - /* interval = */ NULL, + /* interval = */ (plugin_interval > 0) ? &cb_interval : NULL, /* user data = */ &ud); have_instance = 1; @@ -594,8 +600,9 @@ static int varnish_config (oconfig_item_t *ci) /* {{{ */ return (0); } /* }}} int varnish_config */ -void module_register (void) /* {{{ */ +void module_register (plugin_loaddata_t *data) /* {{{ */ { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("varnish", varnish_config); plugin_register_init ("varnish", varnish_init); } /* }}} */ diff --git a/src/vmem.c b/src/vmem.c index 56997bf1..47d10825 100644 --- a/src/vmem.c +++ b/src/vmem.c @@ -40,7 +40,7 @@ static int verbose_output = 0; static void submit (const char *plugin_instance, const char *type, const char *type_instance, value_t *values, int values_len) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); vl.values = values; vl.values_len = values_len; @@ -272,11 +272,13 @@ static int vmem_read (void) return (0); } /* int vmem_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); + plugin_register_config ("vmem", vmem_config, config_keys, config_keys_num); - plugin_register_read ("vmem", vmem_read); + plugin_register_read ("vmem", vmem_read, plugin_interval); } /* void module_register */ /* vim: set sw=2 sts=2 ts=8 : */ diff --git a/src/vserver.c b/src/vserver.c index d80717cd..ee8888ab 100644 --- a/src/vserver.c +++ b/src/vserver.c @@ -51,7 +51,7 @@ static void traffic_submit (const char *plugin_instance, const char *type_instance, derive_t rx, derive_t tx) { value_t values[2]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].derive = rx; values[1].derive = tx; @@ -71,7 +71,7 @@ static void load_submit (const char *plugin_instance, gauge_t snum, gauge_t mnum, gauge_t lnum) { value_t values[3]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = snum; values[1].gauge = mnum; @@ -92,7 +92,7 @@ static void submit_gauge (const char *plugin_instance, const char *type, { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -353,10 +353,11 @@ static int vserver_read (void) return (0); } /* int vserver_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_init ("vserver", vserver_init); - plugin_register_read ("vserver", vserver_read); -} /* void module_register(void) */ + plugin_register_read ("vserver", vserver_read, plugin_interval); +} /* void module_register(plugin_loaddata_t *data) */ /* vim: set ts=4 sw=4 noexpandtab : */ diff --git a/src/wireless.c b/src/wireless.c index f7ba735d..6943a804 100644 --- a/src/wireless.c +++ b/src/wireless.c @@ -49,7 +49,7 @@ static void wireless_submit (const char *plugin_instance, const char *type, double value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -162,7 +162,8 @@ static int wireless_read (void) return (0); } /* int wireless_read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { - plugin_register_read ("wireless", wireless_read); + PLUGIN_INIT_INTERVAL (data); + plugin_register_read ("wireless", wireless_read, plugin_interval); } /* void module_register */ diff --git a/src/write_http.c b/src/write_http.c index 3035e43a..61ac0e7f 100644 --- a/src/write_http.c +++ b/src/write_http.c @@ -590,8 +590,9 @@ static int wh_config (oconfig_item_t *ci) /* {{{ */ return (0); } /* }}} int wh_config */ -void module_register (void) /* {{{ */ +void module_register (plugin_loaddata_t *data) /* {{{ */ { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("write_http", wh_config); } /* }}} void module_register */ diff --git a/src/write_redis.c b/src/write_redis.c index 58f2cae3..58761851 100644 --- a/src/write_redis.c +++ b/src/write_redis.c @@ -230,8 +230,9 @@ static int wr_config (oconfig_item_t *ci) /* {{{ */ return (0); } /* }}} int wr_config */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_complex_config ("write_redis", wr_config); } diff --git a/src/xmms.c b/src/xmms.c index 52beb65f..b9937a50 100644 --- a/src/xmms.c +++ b/src/xmms.c @@ -30,7 +30,7 @@ static gint xmms_session; static void cxmms_submit (const char *type, gauge_t value) { value_t values[1]; - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); values[0].gauge = value; @@ -63,9 +63,10 @@ int cxmms_read (void) return (0); } /* int read */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { - plugin_register_read ("xmms", cxmms_read); + PLUGIN_INIT_INTERVAL (data); + plugin_register_read ("xmms", cxmms_read, plugin_interval); } /* void module_register */ /* diff --git a/src/zfs_arc.c b/src/zfs_arc.c index 8341be0c..4f36f2a4 100644 --- a/src/zfs_arc.c +++ b/src/zfs_arc.c @@ -31,7 +31,7 @@ extern kstat_ctl_t *kc; static void za_submit (const char* type, const char* type_instance, value_t* values, int values_len) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = VALUE_LIST_INIT (plugin_interval); vl.values = values; vl.values_len = values_len; @@ -156,10 +156,11 @@ static int za_init (void) /* {{{ */ return (0); } /* }}} int za_init */ -void module_register (void) +void module_register (plugin_loaddata_t *data) { + PLUGIN_INIT_INTERVAL (data); plugin_register_init ("zfs_arc", za_init); - plugin_register_read ("zfs_arc", za_read); + plugin_register_read ("zfs_arc", za_read, plugin_interval); } /* void module_register */ /* vmi: set sw=8 noexpandtab fdm=marker : */