summaryrefslogtreecommitdiffstats
path: root/web/api
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:19:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:20:02 +0000
commit58daab21cd043e1dc37024a7f99b396788372918 (patch)
tree96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /web/api
parentReleasing debian version 1.43.2-1. (diff)
downloadnetdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz
netdata-58daab21cd043e1dc37024a7f99b396788372918.zip
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/api')
-rw-r--r--web/api/formatters/charts2json.c99
-rw-r--r--web/api/formatters/charts2json.h2
-rw-r--r--web/api/formatters/json_wrapper.c6
-rw-r--r--web/api/formatters/rrd2json.c7
-rw-r--r--web/api/formatters/rrdset2json.c195
-rw-r--r--web/api/formatters/rrdset2json.h2
-rw-r--r--web/api/health/README.md4
-rw-r--r--web/api/queries/query.c4
-rw-r--r--web/api/queries/weights.c6
-rw-r--r--web/api/web_api_v1.c17
10 files changed, 131 insertions, 211 deletions
diff --git a/web/api/formatters/charts2json.c b/web/api/formatters/charts2json.c
index 61086ab63..cab4debae 100644
--- a/web/api/formatters/charts2json.c
+++ b/web/api/formatters/charts2json.c
@@ -36,9 +36,9 @@ const char* get_release_channel() {
return (use_stable)?"stable":"nightly";
}
-void charts2json(RRDHOST *host, BUFFER *wb, int skip_volatile) {
+void charts2json(RRDHOST *host, BUFFER *wb) {
static char *custom_dashboard_info_js_filename = NULL;
- size_t c, dimensions = 0, memory = 0, alarms = 0;
+ size_t c = 0, dimensions = 0, memory = 0, alarms = 0;
RRDSET *st;
time_t now = now_realtime_sec();
@@ -46,42 +46,31 @@ void charts2json(RRDHOST *host, BUFFER *wb, int skip_volatile) {
if(unlikely(!custom_dashboard_info_js_filename))
custom_dashboard_info_js_filename = config_get(CONFIG_SECTION_WEB, "custom dashboard_info.js", "");
- buffer_sprintf(wb, "{\n"
- "\t\"hostname\": \"%s\""
- ",\n\t\"version\": \"%s\""
- ",\n\t\"release_channel\": \"%s\""
- ",\n\t\"os\": \"%s\""
- ",\n\t\"timezone\": \"%s\""
- ",\n\t\"update_every\": %d"
- ",\n\t\"history\": %d"
- ",\n\t\"memory_mode\": \"%s\""
- ",\n\t\"custom_info\": \"%s\""
- ",\n\t\"charts\": {"
- , rrdhost_hostname(host)
- , rrdhost_program_version(host)
- , get_release_channel()
- , rrdhost_os(host)
- , rrdhost_timezone(host)
- , host->rrd_update_every
- , host->rrd_history_entries
- , rrd_memory_mode_name(host->rrd_memory_mode)
- , custom_dashboard_info_js_filename
- );
+ buffer_json_initialize(wb, "\"", "\"", 0, true, BUFFER_JSON_OPTIONS_DEFAULT);
- c = 0;
+ buffer_json_member_add_string(wb, "hostname", rrdhost_hostname(host));
+ buffer_json_member_add_string(wb, "version", rrdhost_program_version(host));
+ buffer_json_member_add_string(wb, "release_channel", get_release_channel());
+ buffer_json_member_add_string(wb, "os", rrdhost_os(host));
+ buffer_json_member_add_string(wb, "timezone", rrdhost_timezone(host));
+ buffer_json_member_add_int64(wb, "update_every", host->rrd_update_every);
+ buffer_json_member_add_int64(wb, "history", host->rrd_history_entries);
+ buffer_json_member_add_string(wb, "memory_mode", rrd_memory_mode_name(host->rrd_memory_mode));
+ buffer_json_member_add_string(wb, "custom_info", custom_dashboard_info_js_filename);
+
+ buffer_json_member_add_object(wb, "charts");
rrdset_foreach_read(st, host) {
if (rrdset_is_available_for_viewers(st)) {
- if(c) buffer_strcat(wb, ",");
- buffer_strcat(wb, "\n\t\t\"");
- buffer_strcat(wb, rrdset_id(st));
- buffer_strcat(wb, "\": ");
- rrdset2json(st, wb, &dimensions, &memory, skip_volatile);
- c++;
+ buffer_json_member_add_object(wb, rrdset_id(st));
+ rrdset2json(st, wb, &dimensions, &memory);
+ buffer_json_object_close(wb);
st->last_accessed_time_s = now;
+ c++;
}
}
rrdset_foreach_done(st);
+ buffer_json_object_close(wb);
RRDCALC *rc;
foreach_rrdcalc_in_rrdhost_read(host, rc) {
@@ -90,50 +79,26 @@ void charts2json(RRDHOST *host, BUFFER *wb, int skip_volatile) {
}
foreach_rrdcalc_in_rrdhost_done(rc);
- buffer_sprintf(wb
- , "\n\t}"
- ",\n\t\"charts_count\": %zu"
- ",\n\t\"dimensions_count\": %zu"
- ",\n\t\"alarms_count\": %zu"
- ",\n\t\"rrd_memory_bytes\": %zu"
- ",\n\t\"hosts_count\": %zu"
- ",\n\t\"hosts\": ["
- , c
- , dimensions
- , alarms
- , memory
- , rrdhost_hosts_available()
- );
+ buffer_json_member_add_int64(wb, "charts_count", (int64_t) c);
+ buffer_json_member_add_int64(wb, "dimensions_count", (int64_t) dimensions);
+ buffer_json_member_add_int64(wb, "alarms_count", (int64_t)alarms);
+ buffer_json_member_add_int64(wb, "rrd_memory_bytes", (int64_t)memory);
+ buffer_json_member_add_int64(wb, "hosts_count", (int64_t) rrdhost_hosts_available());
- if(unlikely(rrdhost_hosts_available() > 1)) {
+ buffer_json_member_add_array(wb, "hosts");
+ {
rrd_rdlock();
-
- size_t found = 0;
RRDHOST *h;
rrdhost_foreach_read(h) {
- if(!rrdhost_should_be_removed(h, host, now) && !rrdhost_flag_check(h, RRDHOST_FLAG_ARCHIVED)) {
- buffer_sprintf(wb
- , "%s\n\t\t{"
- "\n\t\t\t\"hostname\": \"%s\""
- "\n\t\t}"
- , (found > 0) ? "," : ""
- , rrdhost_hostname(h)
- );
-
- found++;
+ if(!rrdhost_should_be_removed(h, host, now) /*&& !rrdhost_flag_check(h, RRDHOST_FLAG_ARCHIVED) */) {
+ buffer_json_add_array_item_object(wb);
+ buffer_json_member_add_string(wb, "hostname", rrdhost_hostname(h));
+ buffer_json_object_close(wb);
}
}
-
rrd_unlock();
}
- else {
- buffer_sprintf(wb
- , "\n\t\t{"
- "\n\t\t\t\"hostname\": \"%s\""
- "\n\t\t}"
- , rrdhost_hostname(host)
- );
- }
+ buffer_json_array_close(wb);
- buffer_sprintf(wb, "\n\t]\n}\n");
+ buffer_json_finalize(wb);
}
diff --git a/web/api/formatters/charts2json.h b/web/api/formatters/charts2json.h
index 4ef6bc2c8..7b07af5a0 100644
--- a/web/api/formatters/charts2json.h
+++ b/web/api/formatters/charts2json.h
@@ -5,7 +5,7 @@
#include "rrd2json.h"
-void charts2json(RRDHOST *host, BUFFER *wb, int skip_volatile);
+void charts2json(RRDHOST *host, BUFFER *wb);
const char* get_release_channel();
#endif //NETDATA_API_FORMATTER_CHARTS2JSON_H
diff --git a/web/api/formatters/json_wrapper.c b/web/api/formatters/json_wrapper.c
index baa39e228..708a0f1f1 100644
--- a/web/api/formatters/json_wrapper.c
+++ b/web/api/formatters/json_wrapper.c
@@ -874,7 +874,8 @@ void rrdr_json_wrapper_begin(RRDR *r, BUFFER *wb) {
sq[0] = '"';
}
- buffer_json_initialize(wb, kq, sq, 0, true, (options & RRDR_OPTION_MINIFY) ? BUFFER_JSON_OPTIONS_MINIFY : BUFFER_JSON_OPTIONS_DEFAULT);
+ buffer_json_initialize(
+ wb, kq, sq, 0, true, (options & RRDR_OPTION_MINIFY) ? BUFFER_JSON_OPTIONS_MINIFY : BUFFER_JSON_OPTIONS_DEFAULT);
buffer_json_member_add_uint64(wb, "api", 1);
buffer_json_member_add_string(wb, "id", qt->id);
@@ -1289,7 +1290,8 @@ void rrdr_json_wrapper_begin2(RRDR *r, BUFFER *wb) {
sq[0] = '\'';
}
- buffer_json_initialize(wb, kq, sq, 0, true, (options & RRDR_OPTION_MINIFY) ? BUFFER_JSON_OPTIONS_MINIFY : BUFFER_JSON_OPTIONS_DEFAULT);
+ buffer_json_initialize(
+ wb, kq, sq, 0, true, (options & RRDR_OPTION_MINIFY) ? BUFFER_JSON_OPTIONS_MINIFY : BUFFER_JSON_OPTIONS_DEFAULT);
buffer_json_member_add_uint64(wb, "api", 2);
if(options & RRDR_OPTION_DEBUG) {
diff --git a/web/api/formatters/rrd2json.c b/web/api/formatters/rrd2json.c
index 52ab31f1b..81c9ad5c7 100644
--- a/web/api/formatters/rrd2json.c
+++ b/web/api/formatters/rrd2json.c
@@ -3,8 +3,11 @@
#include "web/api/web_api_v1.h"
#include "database/storage_engine.h"
-void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb) {
- rrdset2json(st, wb, NULL, NULL, 0);
+void rrd_stats_api_v1_chart(RRDSET *st, BUFFER *wb)
+{
+ buffer_json_initialize(wb, "\"", "\"", 0, true, BUFFER_JSON_OPTIONS_DEFAULT);
+ rrdset2json(st, wb, NULL, NULL);
+ buffer_json_finalize(wb);
}
const char *rrdr_format_to_string(DATASOURCE_FORMAT format) {
diff --git a/web/api/formatters/rrdset2json.c b/web/api/formatters/rrdset2json.c
index 04250dd68..9ada35336 100644
--- a/web/api/formatters/rrdset2json.c
+++ b/web/api/formatters/rrdset2json.c
@@ -2,154 +2,105 @@
#include "rrdset2json.h"
-void chart_labels2json(RRDSET *st, BUFFER *wb, size_t indentation)
+static int process_label_callback(const char *name, const char *value, RRDLABEL_SRC ls, void *data) {
+ BUFFER *wb = data;
+ buffer_json_member_add_string_or_empty(wb, name, value);
+ return 1;
+}
+
+void chart_labels2json(RRDSET *st, BUFFER *wb)
{
if(unlikely(!st->rrdlabels))
return;
- char tabs[11];
-
- if (indentation > 10)
- indentation = 10;
-
- tabs[0] = '\0';
- while (indentation) {
- strcat(tabs, "\t\t");
- indentation--;
- }
-
- rrdlabels_to_buffer(st->rrdlabels, wb, tabs, ":", "\"", ",\n", NULL, NULL, NULL, NULL);
- buffer_strcat(wb, "\n");
+ rrdlabels_walkthrough_read(st->rrdlabels, process_label_callback, wb);
}
// generate JSON for the /api/v1/chart API call
-
-void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memory_used, int skip_volatile) {
+void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memory_used)
+{
time_t first_entry_t = rrdset_first_entry_s(st);
time_t last_entry_t = rrdset_last_entry_s(st);
-
- buffer_sprintf(
- wb,
- "\t\t{\n"
- "\t\t\t\"id\": \"%s\",\n"
- "\t\t\t\"name\": \"%s\",\n"
- "\t\t\t\"type\": \"%s\",\n"
- "\t\t\t\"family\": \"%s\",\n"
- "\t\t\t\"context\": \"%s\",\n"
- "\t\t\t\"title\": \"%s (%s)\",\n"
- "\t\t\t\"priority\": %d,\n"
- "\t\t\t\"plugin\": \"%s\",\n"
- "\t\t\t\"module\": \"%s\",\n"
- "\t\t\t\"units\": \"%s\",\n"
- "\t\t\t\"data_url\": \"/api/v1/data?chart=%s\",\n"
- "\t\t\t\"chart_type\": \"%s\",\n",
- rrdset_id(st),
- rrdset_name(st),
- rrdset_parts_type(st),
- rrdset_family(st),
- rrdset_context(st),
- rrdset_title(st),
- rrdset_name(st),
- st->priority,
- rrdset_plugin_name(st),
- rrdset_module_name(st),
- rrdset_units(st),
- rrdset_name(st),
- rrdset_type_name(st->chart_type));
-
- if (likely(!skip_volatile))
- buffer_sprintf(
- wb,
- "\t\t\t\"duration\": %"PRId64",\n",
- (int64_t)(last_entry_t - first_entry_t + st->update_every) //st->entries * st->update_every
- );
-
- buffer_sprintf(
- wb,
- "\t\t\t\"first_entry\": %"PRId64",\n",
- (int64_t)first_entry_t //rrdset_first_entry_t(st)
- );
-
- if (likely(!skip_volatile))
- buffer_sprintf(
- wb,
- "\t\t\t\"last_entry\": %"PRId64",\n",
- (int64_t)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);
+ char buf[RRD_ID_LENGTH_MAX + 16];
+
+ buffer_json_member_add_string(wb, "id", rrdset_id(st));
+ buffer_json_member_add_string(wb, "name", rrdset_name(st));
+ buffer_json_member_add_string(wb, "type", rrdset_parts_type(st));
+ buffer_json_member_add_string(wb, "family", rrdset_family(st));
+ buffer_json_member_add_string(wb, "context", rrdset_context(st));
+ snprintfz(buf, RRD_ID_LENGTH_MAX + 15, "%s (%s)", rrdset_title(st), rrdset_name(st));
+ buffer_json_member_add_string(wb, "title", buf);
+ buffer_json_member_add_int64(wb, "priority", st->priority);
+ buffer_json_member_add_string(wb, "plugin", rrdset_plugin_name(st));
+ buffer_json_member_add_string(wb, "module", rrdset_module_name(st));
+ buffer_json_member_add_string(wb, "units", rrdset_units(st));
+
+ snprintfz(buf, RRD_ID_LENGTH_MAX + 15, "/api/v1/data?chart=%s", rrdset_name(st));
+ buffer_json_member_add_string(wb, "data_url", buf);
+
+ buffer_json_member_add_string(wb, "chart_type", rrdset_type_name(st->chart_type));
+ buffer_json_member_add_int64(wb, "duration", (int64_t)(last_entry_t - first_entry_t + st->update_every));
+ buffer_json_member_add_int64(wb, "first_entry", (int64_t)first_entry_t);
+ buffer_json_member_add_int64(wb, "last_entry", (int64_t)last_entry_t);
+ buffer_json_member_add_int64(wb, "update_every", (int64_t)st->update_every);
unsigned long memory = sizeof(RRDSET);
size_t dimensions = 0;
- RRDDIM *rd;
- rrddim_foreach_read(rd, st) {
- if(rrddim_option_check(rd, RRDDIM_OPTION_HIDDEN) || rrddim_flag_check(rd, RRDDIM_FLAG_OBSOLETE)) continue;
-
- memory += rrddim_size() + rd->db.memsize;
-
- if (dimensions)
- buffer_strcat(wb, ",\n\t\t\t\t\"");
- else
- buffer_strcat(wb, "\t\t\t\t\"");
- buffer_json_strcat(wb, rrddim_id(rd));
- buffer_strcat(wb, "\": { \"name\": \"");
- buffer_json_strcat(wb, rrddim_name(rd));
- buffer_strcat(wb, "\" }");
-
- dimensions++;
+ buffer_json_member_add_object(wb, "dimensions");
+ {
+ RRDDIM *rd;
+ rrddim_foreach_read(rd, st)
+ {
+ if (rrddim_option_check(rd, RRDDIM_OPTION_HIDDEN) || rrddim_flag_check(rd, RRDDIM_FLAG_OBSOLETE))
+ continue;
+
+ memory += rrddim_size() + rd->db.memsize;
+
+ buffer_json_member_add_object(wb, rrddim_id(rd));
+ buffer_json_member_add_string(wb, "name", rrddim_name(rd));
+ buffer_json_object_close(wb);
+
+ dimensions++;
+ }
+ rrddim_foreach_done(rd);
}
- rrddim_foreach_done(rd);
+ buffer_json_object_close(wb);
if(dimensions_count) *dimensions_count += dimensions;
if(memory_used) *memory_used += memory;
- buffer_sprintf(wb, "\n\t\t\t},\n\t\t\t\"chart_variables\": ");
+ buffer_json_member_add_object(wb, "chart_variables");
health_api_v1_chart_custom_variables2json(st, wb);
+ buffer_json_object_close(wb);
- buffer_strcat(wb, ",\n\t\t\t\"green\": ");
- buffer_print_netdata_double(wb, st->green);
- buffer_strcat(wb, ",\n\t\t\t\"red\": ");
- buffer_print_netdata_double(wb, st->red);
+ buffer_json_member_add_double(wb, "green", st->green);
+ buffer_json_member_add_double(wb, "red", st->red);
- if (likely(!skip_volatile)) {
- buffer_strcat(wb, ",\n\t\t\t\"alarms\": {\n");
- size_t alarms = 0;
+ {
+ buffer_json_member_add_object(wb, "alarms");
RRDCALC *rc;
rw_spinlock_read_lock(&st->alerts.spinlock);
- DOUBLE_LINKED_LIST_FOREACH_FORWARD(st->alerts.base, rc, prev, 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" : "", rrdcalc_name(rc), rc->id, rrdcalc_status2string(rc->status), rrdcalc_units(rc),
- rc->update_every);
-
- alarms++;
+ DOUBLE_LINKED_LIST_FOREACH_FORWARD(st->alerts.base, rc, prev, next)
+ {
+ {
+ buffer_json_member_add_object(wb, rrdcalc_name(rc));
+ buffer_json_member_add_string_or_empty(wb, "id", rrdcalc_name(rc));
+ buffer_json_member_add_string_or_empty(wb, "status", rrdcalc_status2string(rc->status));
+ buffer_json_member_add_string_or_empty(wb, "units", rrdcalc_units(rc));
+ buffer_json_member_add_int64(wb, "duration", (int64_t)rc->update_every);
+ buffer_json_object_close(wb);
+ }
}
rw_spinlock_read_unlock(&st->alerts.spinlock);
- buffer_sprintf(wb,
- "\n\t\t\t}"
- );
+ buffer_json_object_close(wb);
}
- buffer_strcat(wb, ",\n\t\t\t\"chart_labels\": {\n");
- chart_labels2json(st, wb, 2);
- buffer_strcat(wb, "\t\t\t}");
- buffer_strcat(wb, ",\n\t\t\t\"functions\": {\n");
- chart_functions2json(st, wb, 4, "\"", "\"");
- buffer_strcat(wb, "\t\t\t}");
+ buffer_json_member_add_object(wb, "chart_labels");
+ chart_labels2json(st, wb);
+ buffer_json_object_close(wb);
- buffer_sprintf(wb,
- "\n\t\t}"
- );
+ buffer_json_member_add_object(wb, "functions");
+ chart_functions2json(st, wb);
+ buffer_json_object_close(wb);
}
diff --git a/web/api/formatters/rrdset2json.h b/web/api/formatters/rrdset2json.h
index b2908e225..8b325c65d 100644
--- a/web/api/formatters/rrdset2json.h
+++ b/web/api/formatters/rrdset2json.h
@@ -5,6 +5,6 @@
#include "rrd2json.h"
-void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memory_used, int skip_volatile);
+void rrdset2json(RRDSET *st, BUFFER *wb, size_t *dimensions_count, size_t *memory_used);
#endif //NETDATA_API_FORMATTER_RRDSET2JSON_H
diff --git a/web/api/health/README.md b/web/api/health/README.md
index 90ad6455a..b8e2c7291 100644
--- a/web/api/health/README.md
+++ b/web/api/health/README.md
@@ -86,14 +86,14 @@ If you've configured and entered your token correctly, you should see the plain
If all you need is temporarily disable all health checks, then you issue the following before your maintenance period starts:
```sh
-curl "http://NODE:19999/api/v1/manage/health?cmd=DISABLE ALL" -H "X-Auth-Token: Mytoken"
+curl "http://NODE:19999/api/v1/manage/health?cmd=DISABLE%20ALL" -H "X-Auth-Token: Mytoken"
```
The effect of disabling health checks is that the alert criteria are not evaluated at all and nothing is written in the alert log.
If you want the health checks to be running but to not receive any notifications during your maintenance period, you can instead use this:
```sh
-curl "http://NODE:19999/api/v1/manage/health?cmd=SILENCE ALL" -H "X-Auth-Token: Mytoken"
+curl "http://NODE:19999/api/v1/manage/health?cmd=SILENCE%20ALL" -H "X-Auth-Token: Mytoken"
```
Alerts may then still be raised and logged in Netdata, so you'll be able to see them via the UI.
diff --git a/web/api/queries/query.c b/web/api/queries/query.c
index b7e89ee97..76d673cae 100644
--- a/web/api/queries/query.c
+++ b/web/api/queries/query.c
@@ -3617,12 +3617,12 @@ RRDR *rrd2rrdr(ONEWAYALLOC *owa, QUERY_TARGET *qt) {
bool cancel = false;
if (qt->request.interrupt_callback && qt->request.interrupt_callback(qt->request.interrupt_callback_data)) {
cancel = true;
- netdata_log_access("QUERY INTERRUPTED");
+ nd_log(NDLS_ACCESS, NDLP_NOTICE, "QUERY INTERRUPTED");
}
if (qt->request.timeout_ms && ((NETDATA_DOUBLE)(now_ut - qt->timings.received_ut) / 1000.0) > (NETDATA_DOUBLE)qt->request.timeout_ms) {
cancel = true;
- netdata_log_access("QUERY CANCELED RUNTIME EXCEEDED %0.2f ms (LIMIT %lld ms)",
+ nd_log(NDLS_ACCESS, NDLP_WARNING, "QUERY CANCELED RUNTIME EXCEEDED %0.2f ms (LIMIT %lld ms)",
(NETDATA_DOUBLE)(now_ut - qt->timings.received_ut) / 1000.0, (long long)qt->request.timeout_ms);
}
diff --git a/web/api/queries/weights.c b/web/api/queries/weights.c
index fce7b8f24..68af2250f 100644
--- a/web/api/queries/weights.c
+++ b/web/api/queries/weights.c
@@ -112,7 +112,7 @@ static void register_result(DICTIONARY *results, RRDHOST *host, RRDCONTEXT_ACQUI
// we can use the pointer address or RMA as a unique key for each metric
char buf[20 + 1];
- ssize_t len = snprintfz(buf, 20, "%p", rma);
+ ssize_t len = snprintfz(buf, sizeof(buf) - 1, "%p", rma);
dictionary_set_advanced(results, buf, len + 1, &t, sizeof(struct register_result), NULL);
}
@@ -717,7 +717,7 @@ static inline struct dict_unique_name_units *dict_unique_name_units_add(DICTIONA
static inline struct dict_unique_id_name *dict_unique_id_name_add(DICTIONARY *dict, const char *id, const char *name, ssize_t *max_id) {
char key[1024 + 1];
- snprintfz(key, 1024, "%s:%s", id, name);
+ snprintfz(key, sizeof(key) - 1, "%s:%s", id, name);
struct dict_unique_id_name *dun = dictionary_set(dict, key, NULL, sizeof(struct dict_unique_id_name));
if(!dun->existing) {
dun->existing = true;
@@ -2047,7 +2047,7 @@ print("\nprob", prob)
static int double_expect(double v, const char *str, const char *descr) {
char buf[100 + 1];
- snprintfz(buf, 100, "%0.6f", v);
+ snprintfz(buf, sizeof(buf) - 1, "%0.6f", v);
int ret = strcmp(buf, str) ? 1 : 0;
fprintf(stderr, "%s %s, expected %s, got %s\n", ret?"FAILED":"OK", descr, str, buf);
diff --git a/web/api/web_api_v1.c b/web/api/web_api_v1.c
index 648864017..e08f8aa2f 100644
--- a/web/api/web_api_v1.c
+++ b/web/api/web_api_v1.c
@@ -444,7 +444,7 @@ inline int web_client_api_request_v1_alarm_count(RRDHOST *host, struct web_clien
}
inline int web_client_api_request_v1_alarm_log(RRDHOST *host, struct web_client *w, char *url) {
- uint32_t after = 0;
+ time_t after = 0;
char *chart = NULL;
while(url) {
@@ -455,7 +455,7 @@ inline int web_client_api_request_v1_alarm_log(RRDHOST *host, struct web_client
if(!name || !*name) continue;
if(!value || !*value) continue;
- if (!strcmp(name, "after")) after = (uint32_t)strtoul(value, NULL, 0);
+ if (!strcmp(name, "after")) after = (time_t) strtoul(value, NULL, 0);
else if (!strcmp(name, "chart")) chart = value;
}
@@ -644,7 +644,7 @@ inline int web_client_api_request_v1_charts(RRDHOST *host, struct web_client *w,
buffer_flush(w->response.data);
w->response.data->content_type = CT_APPLICATION_JSON;
- charts2json(host, w->response.data, 0);
+ charts2json(host, w->response.data);
return HTTP_RESP_OK;
}
@@ -1272,12 +1272,8 @@ inline int web_client_api_request_v1_info_fill_buffer(RRDHOST *host, BUFFER *wb)
buffer_json_member_add_boolean(wb, "web-enabled", web_server_mode != WEB_SERVER_MODE_NONE);
buffer_json_member_add_boolean(wb, "stream-enabled", default_rrdpush_enabled);
-#ifdef ENABLE_RRDPUSH_COMPRESSION
buffer_json_member_add_boolean(wb, "stream-compression",
- host->sender && stream_has_capability(host->sender, STREAM_CAP_COMPRESSION));
-#else // ! ENABLE_RRDPUSH_COMPRESSION
- buffer_json_member_add_boolean(wb, "stream-compression", false);
-#endif // ENABLE_RRDPUSH_COMPRESSION
+ host->sender && host->sender->compressor.initialized);
#ifdef ENABLE_HTTPS
buffer_json_member_add_boolean(wb, "https-enabled", true);
@@ -1414,7 +1410,10 @@ int web_client_api_request_v1_function(RRDHOST *host, struct web_client *w, char
wb->content_type = CT_APPLICATION_JSON;
buffer_no_cacheable(wb);
- return rrd_function_run(host, wb, timeout, function, true, NULL,
+ char transaction[UUID_COMPACT_STR_LEN];
+ uuid_unparse_lower_compact(w->transaction, transaction);
+
+ return rrd_function_run(host, wb, timeout, function, true, transaction,
NULL, NULL,
web_client_interrupt_callback, w, NULL);
}