char *cacert;
struct curl_slist *headers;
char *post_body;
- cdtime_t interval;
int timeout;
curl_stats_t *stats;
#ifdef HAVE_CURLOPT_TIMEOUT_MS
if (db->timeout >= 0)
curl_easy_setopt(db->curl, CURLOPT_TIMEOUT_MS, (long)db->timeout);
- else if (db->interval > 0)
- curl_easy_setopt(db->curl, CURLOPT_TIMEOUT_MS,
- (long)CDTIME_T_TO_MS(db->interval));
else
curl_easy_setopt(db->curl, CURLOPT_TIMEOUT_MS,
(long)CDTIME_T_TO_MS(plugin_get_interval()));
{
cj_t *db;
int status = 0;
+ cdtime_t interval = 0;
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
WARNING("curl_json plugin: The `URL' block "
else if (strcasecmp("Key", child->key) == 0)
status = cj_config_add_key(db, child);
else if (strcasecmp("Interval", child->key) == 0)
- status = cf_util_get_cdtime(child, &db->interval);
+ status = cf_util_get_cdtime(child, &interval);
else if (strcasecmp("Timeout", child->key) == 0)
status = cf_util_get_int(child, &db->timeout);
else if (strcasecmp("Statistics", child->key) == 0) {
cb_name = ssnprintf_alloc("curl_json-%s-%s", db->instance,
db->url ? db->url : db->sock);
- plugin_register_complex_read(/* group = */ NULL, cb_name, cj_read,
- /* interval = */ db->interval,
+ plugin_register_complex_read(/* group = */ NULL, cb_name, cj_read, interval,
&(user_data_t){
.data = db, .free_func = cj_free,
});
sstrncpy(vl.plugin_instance, db->instance, sizeof(vl.plugin_instance));
sstrncpy(vl.type, key->type, sizeof(vl.type));
- if (db->interval > 0)
- vl.interval = db->interval;
-
plugin_dispatch_values(&vl);
} /* }}} int cj_submit_impl */
char *select_db;
char *plugin_name;
- cdtime_t interval;
-
char *driver;
char *host;
cdbi_driver_option_t *driver_options;
static int cdbi_config_add_database(oconfig_item_t *ci) /* {{{ */
{
+ cdtime_t interval = 0;
cdbi_database_t *db;
int status;
else if (strcasecmp("Host", child->key) == 0)
status = cf_util_get_string(child, &db->host);
else if (strcasecmp("Interval", child->key) == 0)
- status = cf_util_get_cdtime(child, &db->interval);
+ status = cf_util_get_cdtime(child, &interval);
else if (strcasecmp("Plugin", child->key) == 0)
status = cf_util_get_string(child, &db->plugin_name);
else {
/* group = */ NULL,
/* name = */ name ? name : db->name,
/* callback = */ cdbi_read_database,
- /* interval = */ (db->interval > 0) ? db->interval : 0,
+ /* interval = */ interval,
&(user_data_t){
.data = db,
});
status = udb_query_prepare_result(
q, prep_area, (db->host ? db->host : hostname_g),
/* plugin = */ (db->plugin_name != NULL) ? db->plugin_name : "dbi",
- db->name, column_names, column_num,
- /* interval = */ (db->interval > 0) ? db->interval : 0);
+ db->name, column_names, column_num);
if (status != 0) {
ERROR("dbi plugin: udb_query_prepare_result failed with status %i.",
int port; /* for Modbus/TCP */
int baudrate; /* for Modbus/RTU */
mb_conntype_t conntype;
- cdtime_t interval;
mb_slave_t *slaves;
size_t slaves_num;
if ((host == NULL) || (slave == NULL) || (data == NULL))
return EINVAL;
- if (host->interval == 0)
- host->interval = plugin_get_interval();
-
if (slave->instance[0] == 0)
snprintf(slave->instance, sizeof(slave->instance), "slave_%i", slave->id);
vl.values = &value;
vl.values_len = 1;
- vl.interval = host->interval;
sstrncpy(vl.host, host->host, sizeof(vl.host));
sstrncpy(vl.plugin, "modbus", sizeof(vl.plugin));
sstrncpy(vl.plugin_instance, slave->instance, sizeof(vl.plugin_instance));
static int mb_config_add_host(oconfig_item_t *ci) /* {{{ */
{
+ cdtime_t interval = 0;
mb_host_t *host;
int status;
} else if (strcasecmp("Baudrate", child->key) == 0)
status = cf_util_get_int(child, &host->baudrate);
else if (strcasecmp("Interval", child->key) == 0)
- status = cf_util_get_cdtime(child, &host->interval);
+ status = cf_util_get_cdtime(child, &interval);
else if (strcasecmp("Slave", child->key) == 0)
/* Don't set status: Gracefully continue if a slave fails. */
mb_config_add_slave(host, child);
plugin_register_complex_read(/* group = */ NULL, name,
/* callback = */ mb_read,
- /* interval = */ host->interval,
+ /* interval = */ interval,
&(user_data_t){
.data = host, .free_func = host_free,
});
status = udb_query_prepare_result(
q, prep_area, (db->host != NULL) ? db->host : hostname_g,
/* plugin = */ (db->plugin_name != NULL) ? db->plugin_name : "oracle",
- db->name, column_names, column_num,
- /* interval = */ 0);
+ db->name, column_names, column_num);
if (status != 0) {
ERROR("oracle plugin: o_read_database_query (%s, %s): "
"udb_query_prepare_result failed.",
/* make sure we don't access the database object in parallel */
pthread_mutex_t db_lock;
- cdtime_t interval;
-
/* writer "caching" settings */
cdtime_t commit_interval;
cdtime_t next_commit;
pthread_mutex_init(&db->db_lock, /* attrs = */ NULL);
- db->interval = 0;
-
db->commit_interval = 0;
db->next_commit = 0;
db->expire_delay = 0;
params[i] = db->user;
break;
case C_PSQL_PARAM_INTERVAL:
- ;
- cdtime_t tmp = (db->interval > 0) ? db->interval : plugin_get_interval();
- snprintf(interval, sizeof(interval), "%.3f", CDTIME_T_TO_DOUBLE(tmp));
+ snprintf(interval, sizeof(interval), "%.3f",
+ CDTIME_T_TO_DOUBLE(plugin_get_interval()));
params[i] = interval;
break;
case C_PSQL_PARAM_INSTANCE:
status = udb_query_prepare_result(
q, prep_area, host,
(db->plugin_name != NULL) ? db->plugin_name : "postgresql", db->instance,
- column_names, (size_t)column_num, db->interval);
+ column_names, (size_t)column_num);
if (0 != status) {
log_err("udb_query_prepare_result failed with status %i.", status);
static int c_psql_config_database(oconfig_item_t *ci) {
c_psql_database_t *db;
+ cdtime_t interval = 0;
char cb_name[DATA_MAX_NAME_LEN];
static bool have_flush;
config_add_writer(c, writers, writers_num, &db->writers,
&db->writers_num);
else if (0 == strcasecmp(c->key, "Interval"))
- cf_util_get_cdtime(c, &db->interval);
+ cf_util_get_cdtime(c, &interval);
else if (strcasecmp("CommitInterval", c->key) == 0)
cf_util_get_cdtime(c, &db->commit_interval);
else if (strcasecmp("ExpireDelay", c->key) == 0)
if (db->queries_num > 0) {
++db->ref_cnt;
- plugin_register_complex_read("postgresql", cb_name, c_psql_read,
- /* interval = */ db->interval, &ud);
+ plugin_register_complex_read("postgresql", cb_name, c_psql_read, interval,
+ &ud);
}
if (db->writers_num > 0) {
++db->ref_cnt;
void *sess_handle;
c_complain_t complaint;
- cdtime_t interval;
data_definition_t **data_list;
int data_list_len;
};
int status = 0;
/* Registration stuff. */
+ cdtime_t interval = 0;
char cb_name[DATA_MAX_NAME_LEN];
hd = calloc(1, sizeof(*hd));
}
hd->sess_handle = NULL;
- hd->interval = 0;
/* These mean that we have not set a timeout or retry value */
hd->timeout = 0;
else if (strcasecmp("Collect", option->key) == 0)
status = csnmp_config_add_host_collect(hd, option);
else if (strcasecmp("Interval", option->key) == 0)
- status = cf_util_get_cdtime(option, &hd->interval);
+ status = cf_util_get_cdtime(option, &interval);
else if (strcasecmp("Username", option->key) == 0)
status = cf_util_get_string(option, &hd->username);
else if (strcasecmp("AuthProtocol", option->key) == 0)
snprintf(cb_name, sizeof(cb_name), "snmp-%s", hd->name);
status = plugin_register_complex_read(
- /* group = */ NULL, cb_name, csnmp_read_host, hd->interval,
+ /* group = */ NULL, cb_name, csnmp_read_host, interval,
&(user_data_t){
.data = hd, .free_func = csnmp_host_definition_destroy,
});
sstrncpy(vl.plugin, data->plugin_name, sizeof(vl.plugin));
sstrncpy(vl.type, data->type, sizeof(vl.type));
- vl.interval = host->interval;
-
have_more = 1;
while (have_more) {
bool suffix_skipped = 0;
sstrncpy(vl.plugin_instance, data->plugin_instance.value,
sizeof(vl.plugin_instance));
- vl.interval = host->interval;
-
req = snmp_pdu_create(SNMP_MSG_GET);
if (req == NULL) {
ERROR("snmp plugin: snmp_pdu_create failed.");
host = ud->data;
- if (host->interval == 0)
- host->interval = plugin_get_interval();
-
if (host->sess_handle == NULL)
csnmp_host_open_session(host);
int flags;
char *type;
char *type_instance;
- cdtime_t interval;
latency_config_t latency;
};
typedef struct ctail_config_match_s ctail_config_match_t;
-static cu_tail_match_t **tail_match_list;
-static size_t tail_match_list_num;
-static cdtime_t tail_match_list_intervals[255];
+static size_t tail_file_num;
+
+static int ctail_read(user_data_t *ud);
+
+static void ctail_match_free(void *arg) {
+ tail_match_destroy((cu_tail_match_t *)arg);
+} /* void ctail_match_free */
static int ctail_config_add_match_dstype(ctail_config_match_t *cm,
oconfig_item_t *ci) {
static int ctail_config_add_match(cu_tail_match_t *tm, const char *plugin_name,
const char *plugin_instance,
- oconfig_item_t *ci, cdtime_t interval) {
+ oconfig_item_t *ci) {
ctail_config_match_t cm = {0};
int status;
status = tail_match_add_match_simple(
tm, cm.regex, cm.excluderegex, cm.flags,
(plugin_name != NULL) ? plugin_name : "tail", plugin_instance, cm.type,
- cm.type_instance, cm.latency, interval);
+ cm.type_instance, cm.latency);
if (status != 0)
ERROR("tail plugin: tail_match_add_match_simple failed.");
else if (strcasecmp("Interval", option->key) == 0)
cf_util_get_cdtime(option, &interval);
else if (strcasecmp("Match", option->key) == 0) {
- status = ctail_config_add_match(tm, plugin_name, plugin_instance, option,
- interval);
+ status = ctail_config_add_match(tm, plugin_name, plugin_instance, option);
if (status == 0)
num_matches++;
/* Be mild with failed matches.. */
ci->values[0].value.string);
tail_match_destroy(tm);
return -1;
- } else {
- cu_tail_match_t **temp;
-
- temp = realloc(tail_match_list,
- sizeof(cu_tail_match_t *) * (tail_match_list_num + 1));
- if (temp == NULL) {
- ERROR("tail plugin: realloc failed.");
- tail_match_destroy(tm);
- return -1;
- }
-
- tail_match_list = temp;
- tail_match_list[tail_match_list_num] = tm;
- tail_match_list_intervals[tail_match_list_num] = interval;
- tail_match_list_num++;
}
+ char str[255];
+ snprintf(str, sizeof(str), "tail-%zu", tail_file_num++);
+
+ plugin_register_complex_read(
+ NULL, str, ctail_read, interval,
+ &(user_data_t){.data = tm, .free_func = ctail_match_free});
+
return 0;
} /* int ctail_config_add_file */
return 0;
} /* int ctail_read */
-static int ctail_init(void) {
- char str[255];
-
- if (tail_match_list_num == 0) {
- WARNING("tail plugin: File list is empty. Returning an error.");
- return -1;
- }
-
- for (size_t i = 0; i < tail_match_list_num; i++) {
- snprintf(str, sizeof(str), "tail-%zu", i);
-
- plugin_register_complex_read(NULL, str, ctail_read,
- tail_match_list_intervals[i],
- &(user_data_t){
- .data = tail_match_list[i],
- });
- }
-
- return 0;
-} /* int ctail_init */
-
-static int ctail_shutdown(void) {
- for (size_t i = 0; i < tail_match_list_num; i++) {
- tail_match_destroy(tail_match_list[i]);
- tail_match_list[i] = NULL;
- }
- sfree(tail_match_list);
- tail_match_list_num = 0;
-
- return 0;
-} /* int ctail_shutdown */
-
void module_register(void) {
plugin_register_complex_config("tail", ctail_config);
- plugin_register_init("tail", ctail_init);
- plugin_register_shutdown("tail", ctail_shutdown);
} /* void module_register */
cu_tail_t *tail;
metric_definition_t **metric_list;
size_t metric_list_len;
- cdtime_t interval;
ssize_t time_from;
struct instance_definition_s *next;
};
sstrncpy(vl.type_instance, md->instance, sizeof(vl.type_instance));
vl.time = t;
- vl.interval = id->interval;
return plugin_dispatch_values(&vl);
}
int status = 0;
/* Registration variables */
+ cdtime_t interval = 0;
char cb_name[DATA_MAX_NAME_LEN];
id = calloc(1, sizeof(*id));
return status;
}
- /* Use default interval. */
- id->interval = plugin_get_interval();
-
for (int i = 0; i < ci->children_num; ++i) {
oconfig_item_t *option = ci->children + i;
status = 0;
else if (strcasecmp("Collect", option->key) == 0)
status = tcsv_config_add_instance_collect(id, option);
else if (strcasecmp("Interval", option->key) == 0)
- cf_util_get_cdtime(option, &id->interval);
+ cf_util_get_cdtime(option, &interval);
else if (strcasecmp("TimeFrom", option->key) == 0)
status = tcsv_config_get_index(option, &id->time_from);
else if (strcasecmp("Plugin", option->key) == 0)
snprintf(cb_name, sizeof(cb_name), "tail_csv/%s", id->path);
status = plugin_register_complex_read(
- NULL, cb_name, tcsv_read, id->interval,
+ NULL, cb_name, tcsv_read, interval,
&(user_data_t){
.data = id, .free_func = tcsv_instance_definition_destroy,
});
char *plugin;
char *db_name;
- cdtime_t interval;
-
udb_result_preparation_area_t *result_prep_areas;
}; /* }}} */
}
}
- if (q_area->interval > 0)
- vl.interval = q_area->interval;
-
sstrncpy(vl.host, q_area->host, sizeof(vl.host));
sstrncpy(vl.plugin, q_area->plugin, sizeof(vl.plugin));
sstrncpy(vl.type, r->type, sizeof(vl.type));
sfree(prep_area->plugin);
sfree(prep_area->db_name);
- prep_area->interval = 0;
-
for (r = q->results, r_area = prep_area->result_prep_areas; r != NULL;
r = r->next, r_area = r_area->next) {
/* this may happen during error conditions of the caller */
udb_query_preparation_area_t *prep_area,
const char *host, const char *plugin,
const char *db_name, char **column_names,
- size_t column_num, cdtime_t interval) {
+ size_t column_num) {
udb_result_preparation_area_t *r_area;
udb_result_t *r;
int status;
assert(prep_area->host == NULL);
assert(prep_area->plugin == NULL);
assert(prep_area->db_name == NULL);
- assert(prep_area->interval == 0);
#endif
prep_area->column_num = column_num;
prep_area->plugin = strdup(plugin);
prep_area->db_name = strdup(db_name);
- prep_area->interval = interval;
-
if ((prep_area->host == NULL) || (prep_area->plugin == NULL) ||
(prep_area->db_name == NULL)) {
P_ERROR("Query `%s': Prepare failed: Out of memory.", q->name);
udb_query_preparation_area_t *prep_area,
const char *host, const char *plugin,
const char *db_name, char **column_names,
- size_t column_num, cdtime_t interval);
+ size_t column_num);
int udb_query_handle_result(udb_query_t const *q,
udb_query_preparation_area_t *prep_area,
char **column_values);
char plugin_instance[DATA_MAX_NAME_LEN];
char type[DATA_MAX_NAME_LEN];
char type_instance[DATA_MAX_NAME_LEN];
- cdtime_t interval;
latency_config_t latency_config;
};
typedef struct cu_tail_match_simple_s cu_tail_match_simple_t;
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);
match_value_reset(match_value);
sstrncpy(vl.plugin, data->plugin, sizeof(vl.plugin));
sstrncpy(vl.plugin_instance, data->plugin_instance,
sizeof(vl.plugin_instance));
- vl.interval = data->interval;
vl.time = cdtime();
/* Submit percentiles */
obj->matches = temp;
obj->matches_num++;
- DEBUG("tail_match_add_match interval %lf",
- CDTIME_T_TO_DOUBLE(((cu_tail_match_simple_t *)user_data)->interval));
temp = obj->matches + (obj->matches_num - 1);
temp->match = match;
const char *excluderegex, int ds_type,
const char *plugin, const char *plugin_instance,
const char *type, const char *type_instance,
- const latency_config_t latency_cfg,
- const cdtime_t interval) {
+ const latency_config_t latency_cfg) {
cu_match_t *match;
cu_tail_match_simple_t *user_data;
int status;
sstrncpy(user_data->type_instance, type_instance,
sizeof(user_data->type_instance));
- user_data->interval = interval;
-
if ((ds_type & UTILS_MATCH_DS_TYPE_GAUGE) &&
(ds_type & UTILS_MATCH_CF_GAUGE_DIST)) {
status = latency_config_copy(&user_data->latency_config, latency_cfg);
const char *excluderegex, int ds_type,
const char *plugin, const char *plugin_instance,
const char *type, const char *type_instance,
- const latency_config_t latency_cfg,
- const cdtime_t interval);
+ const latency_config_t latency_cfg);
/*
* NAME