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.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/collectors/plugins.d/pluginsd_parser.c b/collectors/plugins.d/pluginsd_parser.c
index 2d0788d80..c0dcedb67 100644
--- a/collectors/plugins.d/pluginsd_parser.c
+++ b/collectors/plugins.d/pluginsd_parser.c
@@ -152,6 +152,24 @@ PARSER_RC pluginsd_label_action(void *user, char *key, char *value, LABEL_SOURCE
return PARSER_RC_OK;
}
+PARSER_RC pluginsd_clabel_action(void *user, char *key, char *value, LABEL_SOURCE source)
+{
+ ((PARSER_USER_OBJECT *) user)->chart_labels = add_label_to_list(((PARSER_USER_OBJECT *) user)->chart_labels, key, value, source);
+
+ return PARSER_RC_OK;
+}
+
+PARSER_RC pluginsd_clabel_commit_action(void *user, RRDHOST *host, struct label *new_labels)
+{
+ RRDSET *st = ((PARSER_USER_OBJECT *)user)->st;
+ if (unlikely(!st)) {
+ error("requested CLABEL_COMMIT on host '%s', without a BEGIN, ignoring it.", host->hostname);
+ return PARSER_RC_OK;
+ }
+
+ rrdset_update_labels(st, new_labels);
+ return PARSER_RC_OK;
+}
PARSER_RC pluginsd_overwrite_action(void *user, RRDHOST *host, struct label *new_labels)
{
@@ -560,6 +578,38 @@ PARSER_RC pluginsd_label(char **words, void *user, PLUGINSD_ACTION *plugins_act
return PARSER_RC_OK;
}
+PARSER_RC pluginsd_clabel(char **words, void *user, PLUGINSD_ACTION *plugins_action)
+{
+ if (!words[1] || !words[2] || !words[3]) {
+ error("Ignoring malformed or empty CHART LABEL command.");
+ return PARSER_RC_OK;
+ }
+
+ if (plugins_action->clabel_action) {
+ PARSER_RC rc = plugins_action->clabel_action(user, words[1], words[2], strtol(words[3], NULL, 10));
+ return rc;
+ }
+
+ return PARSER_RC_OK;
+}
+
+PARSER_RC pluginsd_clabel_commit(char **words, void *user, PLUGINSD_ACTION *plugins_action)
+{
+ UNUSED(words);
+
+ 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;
+
+ if (plugins_action->clabel_commit_action) {
+ return plugins_action->clabel_commit_action(user, host, chart_labels);
+ }
+
+ return PARSER_RC_OK;
+}
+
PARSER_RC pluginsd_overwrite(char **words, void *user, PLUGINSD_ACTION *plugins_action)
{
UNUSED(words);