summaryrefslogtreecommitdiffstats
path: root/collectors/plugins.d/pluginsd_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/plugins.d/pluginsd_parser.c')
-rw-r--r--collectors/plugins.d/pluginsd_parser.c72
1 files changed, 40 insertions, 32 deletions
diff --git a/collectors/plugins.d/pluginsd_parser.c b/collectors/plugins.d/pluginsd_parser.c
index f014a29d..88e07fab 100644
--- a/collectors/plugins.d/pluginsd_parser.c
+++ b/collectors/plugins.d/pluginsd_parser.c
@@ -96,7 +96,7 @@ PARSER_RC pluginsd_disable_action(void *user)
}
-PARSER_RC pluginsd_variable_action(void *user, RRDHOST *host, RRDSET *st, char *name, int global, calculated_number value)
+PARSER_RC pluginsd_variable_action(void *user, RRDHOST *host, RRDSET *st, char *name, int global, NETDATA_DOUBLE value)
{
UNUSED(user);
@@ -146,35 +146,41 @@ PARSER_RC pluginsd_dimension_action(void *user, RRDSET *st, char *id, char *name
if (likely(unhide_dimension)) {
rrddim_flag_clear(rd, RRDDIM_FLAG_HIDDEN);
if (rrddim_flag_check(rd, RRDDIM_FLAG_META_HIDDEN)) {
- (void)sql_set_dimension_option(&rd->state->metric_uuid, NULL);
+ (void)sql_set_dimension_option(&rd->metric_uuid, NULL);
rrddim_flag_clear(rd, RRDDIM_FLAG_META_HIDDEN);
}
} else {
rrddim_flag_set(rd, RRDDIM_FLAG_HIDDEN);
if (!rrddim_flag_check(rd, RRDDIM_FLAG_META_HIDDEN)) {
- (void)sql_set_dimension_option(&rd->state->metric_uuid, "hidden");
+ (void)sql_set_dimension_option(&rd->metric_uuid, "hidden");
rrddim_flag_set(rd, RRDDIM_FLAG_META_HIDDEN);
}
}
return PARSER_RC_OK;
}
-PARSER_RC pluginsd_label_action(void *user, char *key, char *value, LABEL_SOURCE source)
+PARSER_RC pluginsd_label_action(void *user, char *key, char *value, RRDLABEL_SRC source)
{
- ((PARSER_USER_OBJECT *) user)->new_labels = add_label_to_list(((PARSER_USER_OBJECT *) user)->new_labels, key, value, source);
+ if(unlikely(!((PARSER_USER_OBJECT *) user)->new_host_labels))
+ ((PARSER_USER_OBJECT *) user)->new_host_labels = rrdlabels_create();
+
+ rrdlabels_add(((PARSER_USER_OBJECT *)user)->new_host_labels, key, value, source);
return PARSER_RC_OK;
}
-PARSER_RC pluginsd_clabel_action(void *user, char *key, char *value, LABEL_SOURCE source)
+PARSER_RC pluginsd_clabel_action(void *user, char *key, char *value, RRDLABEL_SRC source)
{
- ((PARSER_USER_OBJECT *) user)->chart_labels = add_label_to_list(((PARSER_USER_OBJECT *) user)->chart_labels, key, value, source);
+ if(unlikely(!((PARSER_USER_OBJECT *) user)->new_chart_labels))
+ ((PARSER_USER_OBJECT *) user)->new_chart_labels = rrdlabels_create();
+
+ rrdlabels_add(((PARSER_USER_OBJECT *)user)->new_chart_labels, key, value, source);
return PARSER_RC_OK;
}
-PARSER_RC pluginsd_clabel_commit_action(void *user, RRDHOST *host, struct label *new_labels)
+PARSER_RC pluginsd_clabel_commit_action(void *user, RRDHOST *host, DICTIONARY *new_chart_labels)
{
RRDSET *st = ((PARSER_USER_OBJECT *)user)->st;
if (unlikely(!st)) {
@@ -182,21 +188,21 @@ PARSER_RC pluginsd_clabel_commit_action(void *user, RRDHOST *host, struct label
return PARSER_RC_OK;
}
- rrdset_update_labels(st, new_labels);
+ rrdset_update_rrdlabels(st, new_chart_labels);
+
return PARSER_RC_OK;
}
-PARSER_RC pluginsd_overwrite_action(void *user, RRDHOST *host, struct label *new_labels)
+PARSER_RC pluginsd_overwrite_action(void *user, RRDHOST *host, DICTIONARY *new_host_labels)
{
UNUSED(user);
- if (!host->labels.head) {
- host->labels.head = new_labels;
- } else {
- rrdhost_rdlock(host);
- replace_label_list(&host->labels, new_labels);
- rrdhost_unlock(host);
- }
+ if(!host->host_labels)
+ host->host_labels = rrdlabels_create();
+
+ rrdlabels_migrate_to_these(host->host_labels, new_host_labels);
+ sql_store_host_labels(host);
+
return PARSER_RC_OK;
}
@@ -468,7 +474,7 @@ PARSER_RC pluginsd_variable(char **words, void *user, PLUGINSD_ACTION *plugins_
{
char *name = words[1];
char *value = words[2];
- calculated_number v;
+ NETDATA_DOUBLE v;
RRDSET *st = ((PARSER_USER_OBJECT *) user)->st;
RRDHOST *host = ((PARSER_USER_OBJECT *) user)->host;
@@ -508,7 +514,7 @@ PARSER_RC pluginsd_variable(char **words, void *user, PLUGINSD_ACTION *plugins_
}
char *endptr = NULL;
- v = (calculated_number)str2ld(value, &endptr);
+ v = (NETDATA_DOUBLE)str2ndd(value, &endptr);
if (unlikely(endptr && *endptr)) {
if (endptr == value)
error(
@@ -615,14 +621,15 @@ PARSER_RC pluginsd_clabel_commit(char **words, void *user, PLUGINSD_ACTION *plu
RRDHOST *host = ((PARSER_USER_OBJECT *) user)->host;
debug(D_PLUGINSD, "requested to commit chart labels");
- struct label *chart_labels = ((PARSER_USER_OBJECT *)user)->chart_labels;
- ((PARSER_USER_OBJECT *)user)->chart_labels = NULL;
+ PARSER_RC rc = PARSER_RC_OK;
- if (plugins_action->clabel_commit_action) {
- return plugins_action->clabel_commit_action(user, host, chart_labels);
- }
+ if (plugins_action->clabel_commit_action)
+ rc = plugins_action->clabel_commit_action(user, host, ((PARSER_USER_OBJECT *)user)->new_chart_labels);
- return PARSER_RC_OK;
+ rrdlabels_destroy(((PARSER_USER_OBJECT *)user)->new_chart_labels);
+ ((PARSER_USER_OBJECT *)user)->new_chart_labels = NULL;
+
+ return rc;
}
PARSER_RC pluginsd_overwrite(char **words, void *user, PLUGINSD_ACTION *plugins_action)
@@ -630,16 +637,17 @@ PARSER_RC pluginsd_overwrite(char **words, void *user, PLUGINSD_ACTION *plugins
UNUSED(words);
RRDHOST *host = ((PARSER_USER_OBJECT *) user)->host;
- debug(D_PLUGINSD, "requested a OVERWRITE a variable");
+ debug(D_PLUGINSD, "requested to OVERWRITE host labels");
- struct label *new_labels = ((PARSER_USER_OBJECT *)user)->new_labels;
- ((PARSER_USER_OBJECT *)user)->new_labels = NULL;
+ PARSER_RC rc = PARSER_RC_OK;
- if (plugins_action->overwrite_action) {
- return plugins_action->overwrite_action(user, host, new_labels);
- }
+ if (plugins_action->overwrite_action)
+ rc = plugins_action->overwrite_action(user, host, ((PARSER_USER_OBJECT *)user)->new_host_labels);
- return PARSER_RC_OK;
+ rrdlabels_destroy(((PARSER_USER_OBJECT *)user)->new_host_labels);
+ ((PARSER_USER_OBJECT *)user)->new_host_labels = NULL;
+
+ return rc;
}
PARSER_RC pluginsd_guid(char **words, void *user, PLUGINSD_ACTION *plugins_action)