diff options
author | Andrew Moss <1043609+amoss@users.noreply.github.com> | 2020-02-24 12:10:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-24 12:10:10 +0100 |
commit | c6d945200f201b05c2b019fa862cdf080a39a9d4 (patch) | |
tree | f061f87ff75a898ee7de82018a2c18935ada09cf /web | |
parent | eeff346ca13af40091980d95de79ad5df50592e1 (diff) |
Merging the feature branch for the ACLK in the previous sprint. (#8179)
* ACLK connection and protocol improvements (#8139)
* Adding ACLK retry on connection failure (#8147)
* Fixed reconnect issues on the ACLK. (#8163)
* Cleaning up ACLK - part 1 (#8167)
Co-authored-by: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com>
Diffstat (limited to 'web')
-rw-r--r-- | web/api/formatters/charts2json.c | 4 | ||||
-rw-r--r-- | web/api/formatters/charts2json.h | 2 | ||||
-rw-r--r-- | web/api/formatters/rrd2json.c | 2 | ||||
-rw-r--r-- | web/api/formatters/rrdset2json.c | 105 | ||||
-rw-r--r-- | web/api/formatters/rrdset2json.h | 2 | ||||
-rw-r--r-- | web/api/web_api_v1.c | 2 |
6 files changed, 65 insertions, 52 deletions
diff --git a/web/api/formatters/charts2json.c b/web/api/formatters/charts2json.c index db3ef37eaf..864387ed51 100644 --- a/web/api/formatters/charts2json.c +++ b/web/api/formatters/charts2json.c @@ -36,7 +36,7 @@ static inline const char* get_release_channel() { return (use_stable)?"stable":"nightly"; } -void charts2json(RRDHOST *host, BUFFER *wb) { +void charts2json(RRDHOST *host, BUFFER *wb, int skip_volatile) { static char *custom_dashboard_info_js_filename = NULL; size_t c, dimensions = 0, memory = 0, alarms = 0; RRDSET *st; @@ -76,7 +76,7 @@ void charts2json(RRDHOST *host, BUFFER *wb) { buffer_strcat(wb, "\n\t\t\""); buffer_strcat(wb, st->id); buffer_strcat(wb, "\": "); - rrdset2json(st, wb, &dimensions, &memory); + rrdset2json(st, wb, &dimensions, &memory, skip_volatile); c++; st->last_accessed_time = now; diff --git a/web/api/formatters/charts2json.h b/web/api/formatters/charts2json.h index 926e76d50b..4f0d57422a 100644 --- a/web/api/formatters/charts2json.h +++ b/web/api/formatters/charts2json.h @@ -5,7 +5,7 @@ #include "rrd2json.h" -extern void charts2json(RRDHOST *host, BUFFER *wb); +extern void charts2json(RRDHOST *host, BUFFER *wb, int skip_volatile); extern void chartcollectors2json(RRDHOST *host, BUFFER *wb); #endif //NETDATA_API_FORMATTER_CHARTS2JSON_H diff --git a/web/api/formatters/rrd2json.c b/web/api/formatters/rrd2json.c index 17b1a301b7..5672c69521 100644 --- a/web/api/formatters/rrd2json.c +++ b/web/api/formatters/rrd2json.c @@ -3,7 +3,7 @@ #include "web/api/web_api_v1.h" void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb) { - rrdset2json(st, wb, NULL, NULL); + rrdset2json(st, wb, NULL, NULL, 0); } void rrdr_buffer_print_format(BUFFER *wb, uint32_t format) { diff --git a/web/api/formatters/rrdset2json.c b/web/api/formatters/rrdset2json.c index 4d91399270..21feceb451 100644 --- a/web/api/formatters/rrdset2json.c +++ b/web/api/formatters/rrdset2json.c @@ -4,7 +4,7 @@ // generate JSON for the /api/v1/chart API call -void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memory_used) { +void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memory_used, int skip_volatile) { rrdset_rdlock(st); time_t first_entry_t = rrdset_first_entry_t(st); @@ -25,30 +25,44 @@ void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memor "\t\t\t\"units\": \"%s\",\n" "\t\t\t\"data_url\": \"/api/v1/data?chart=%s\",\n" "\t\t\t\"chart_type\": \"%s\",\n" - "\t\t\t\"duration\": %ld,\n" - "\t\t\t\"first_entry\": %ld,\n" - "\t\t\t\"last_entry\": %ld,\n" - "\t\t\t\"update_every\": %d,\n" - "\t\t\t\"dimensions\": {\n" - , st->id - , st->name - , st->type - , st->family - , st->context - , st->title, st->name - , st->priority - , st->plugin_name?st->plugin_name:"" - , st->module_name?st->module_name:"" - , rrdset_flag_check(st, RRDSET_FLAG_ENABLED)?"true":"false" - , st->units - , st->name - , rrdset_type_name(st->chart_type) - , last_entry_t - first_entry_t + st->update_every//st->entries * st->update_every - , first_entry_t//rrdset_first_entry_t(st) - , last_entry_t//rrdset_last_entry_t(st) - , st->update_every + , st->id + , st->name + , st->type + , st->family + , st->context + , st->title, st->name + , st->priority + , st->plugin_name?st->plugin_name:"" + , st->module_name?st->module_name:"" + , rrdset_flag_check(st, RRDSET_FLAG_ENABLED)?"true":"false" + , st->units + , st->name + , rrdset_type_name(st->chart_type) ); + if (likely(!skip_volatile)) + buffer_sprintf(wb, + "\t\t\t\"duration\": %ld,\n" + , last_entry_t - first_entry_t + st->update_every//st->entries * st->update_every + ); + + buffer_sprintf(wb, + "\t\t\t\"first_entry\": %ld,\n" + , first_entry_t //rrdset_first_entry_t(st) + ); + + if (likely(!skip_volatile)) + buffer_sprintf(wb, + "\t\t\t\"last_entry\": %ld,\n" + , last_entry_t//rrdset_last_entry_t(st) + ); + + buffer_sprintf(wb, + "\t\t\t\"update_every\": %d,\n" + "\t\t\t\"dimensions\": {\n" + , st->update_every + ); + unsigned long memory = st->memsize; size_t dimensions = 0; @@ -81,33 +95,32 @@ void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memor buffer_strcat(wb, ",\n\t\t\t\"red\": "); buffer_rrd_value(wb, st->red); - buffer_strcat(wb, ",\n\t\t\t\"alarms\": {\n"); - size_t alarms = 0; - RRDCALC *rc; - for(rc = st->alarms; rc ; rc = rc->rrdset_next) { - - buffer_sprintf( - wb - , "%s" - "\t\t\t\t\"%s\": {\n" - "\t\t\t\t\t\"id\": %u,\n" - "\t\t\t\t\t\"status\": \"%s\",\n" - "\t\t\t\t\t\"units\": \"%s\",\n" - "\t\t\t\t\t\"update_every\": %d\n" - "\t\t\t\t}" - , (alarms) ? ",\n" : "" - , rc->name - , rc->id - , rrdcalc_status2string(rc->status) - , rc->units - , rc->update_every + if (likely(!skip_volatile)) { + buffer_strcat(wb, ",\n\t\t\t\"alarms\": {\n"); + size_t alarms = 0; + RRDCALC *rc; + for (rc = st->alarms; rc; rc = rc->rrdset_next) { + buffer_sprintf( + wb, + "%s" + "\t\t\t\t\"%s\": {\n" + "\t\t\t\t\t\"id\": %u,\n" + "\t\t\t\t\t\"status\": \"%s\",\n" + "\t\t\t\t\t\"units\": \"%s\",\n" + "\t\t\t\t\t\"update_every\": %d\n" + "\t\t\t\t}", + (alarms) ? ",\n" : "", rc->name, rc->id, rrdcalc_status2string(rc->status), rc->units, + rc->update_every); + + alarms++; + } + buffer_sprintf(wb, + "\n\t\t\t}" ); - - alarms++; } buffer_sprintf(wb, - "\n\t\t\t}\n\t\t}" + "\n\t\t}" ); rrdset_unlock(st); diff --git a/web/api/formatters/rrdset2json.h b/web/api/formatters/rrdset2json.h index b2669ec0a3..697c846347 100644 --- a/web/api/formatters/rrdset2json.h +++ b/web/api/formatters/rrdset2json.h @@ -5,6 +5,6 @@ #include "rrd2json.h" -extern void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memory_used); +extern void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memory_used, int skip_volatile); #endif //NETDATA_API_FORMATTER_RRDSET2JSON_H diff --git a/web/api/web_api_v1.c b/web/api/web_api_v1.c index 899b604348..316eca3683 100644 --- a/web/api/web_api_v1.c +++ b/web/api/web_api_v1.c @@ -349,7 +349,7 @@ inline int web_client_api_request_v1_charts(RRDHOST *host, struct web_client *w, buffer_flush(w->response.data); w->response.data->contenttype = CT_APPLICATION_JSON; - charts2json(host, w->response.data); + charts2json(host, w->response.data, 0); return HTTP_RESP_OK; } |