summaryrefslogtreecommitdiffstats
path: root/database/rrdvar.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-09-03 10:23:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-09-03 10:23:38 +0000
commit574098461cd45be12a497afbdac6f93c58978387 (patch)
tree9eb60a5930b7c20d42f7fde1e234cae3968ed3d9 /database/rrdvar.c
parentAdding upstream version 1.16.1. (diff)
downloadnetdata-574098461cd45be12a497afbdac6f93c58978387.tar.xz
netdata-574098461cd45be12a497afbdac6f93c58978387.zip
Adding upstream version 1.17.0.upstream/1.17.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--database/rrdvar.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/database/rrdvar.c b/database/rrdvar.c
index 95ab6859e..0858d0bdc 100644
--- a/database/rrdvar.c
+++ b/database/rrdvar.c
@@ -248,6 +248,7 @@ int health_variable_lookup(const char *variable, uint32_t hash, RRDCALC *rc, cal
struct variable2json_helper {
BUFFER *buf;
size_t counter;
+ RRDVAR_OPTIONS options;
};
static int single_variable2json(void *entry, void *data) {
@@ -255,22 +256,37 @@ static int single_variable2json(void *entry, void *data) {
RRDVAR *rv = (RRDVAR *)entry;
calculated_number value = rrdvar2number(rv);
- if(unlikely(isnan(value) || isinf(value)))
- buffer_sprintf(helper->buf, "%s\n\t\t\"%s\": null", helper->counter?",":"", rv->name);
- else
- buffer_sprintf(helper->buf, "%s\n\t\t\"%s\": %0.5" LONG_DOUBLE_MODIFIER, helper->counter?",":"", rv->name, (LONG_DOUBLE)value);
+ if (helper->options == RRDVAR_OPTION_DEFAULT || rv->options & helper->options) {
+ if(unlikely(isnan(value) || isinf(value)))
+ buffer_sprintf(helper->buf, "%s\n\t\t\"%s\": null", helper->counter?",":"", rv->name);
+ else
+ buffer_sprintf(helper->buf, "%s\n\t\t\"%s\": %0.5" LONG_DOUBLE_MODIFIER, helper->counter?",":"", rv->name, (LONG_DOUBLE)value);
- helper->counter++;
+ helper->counter++;
+ }
return 0;
}
+void health_api_v1_chart_custom_variables2json(RRDSET *st, BUFFER *buf) {
+ struct variable2json_helper helper = {
+ .buf = buf,
+ .counter = 0,
+ .options = RRDVAR_OPTION_CUSTOM_CHART_VAR
+ };
+
+ buffer_sprintf(buf, "{");
+ avl_traverse_lock(&st->rrdvar_root_index, single_variable2json, (void *)&helper);
+ buffer_strcat(buf, "\n\t\t\t}");
+}
+
void health_api_v1_chart_variables2json(RRDSET *st, BUFFER *buf) {
RRDHOST *host = st->rrdhost;
struct variable2json_helper helper = {
.buf = buf,
- .counter = 0
+ .counter = 0,
+ .options = RRDVAR_OPTION_DEFAULT
};
buffer_sprintf(buf, "{\n\t\"chart\": \"%s\",\n\t\"chart_name\": \"%s\",\n\t\"chart_context\": \"%s\",\n\t\"chart_variables\": {", st->id, st->name, st->context);