dont add all nodes to registry action hello (#15388)
Costa Tsaousis committed
Jul 13, 2023 at 22:47 UTC
76d10ab2509ca5b42e4c43258c390505617a5f31
2 files changed
+18
-63
registry/registry.c
+18
-11
@@ -58,7 +58,7 @@ static inline void registry_set_person_cookie(struct web_client *w, REGISTRY_PER
58
static inline void registry_json_header(RRDHOST *host, struct web_client *w, const char *action, const char *status) {
59
buffer_flush(w->response.data);
60
w->response.data->content_type = CT_APPLICATION_JSON;
61
- buffer_json_initialize(w->response.data, "\"", "\"", 0, true, false);
61
+ buffer_json_initialize(w->response.data, "\"", "\"", 0, true, true);
62
buffer_json_member_add_string(w->response.data, "action", action);
63
buffer_json_member_add_string(w->response.data, "status", status);
64
buffer_json_member_add_string(w->response.data, "hostname", rrdhost_registry_hostname(host));
@@ -190,18 +190,25 @@ int registry_request_hello_json(RRDHOST *host, struct web_client *w) {
190
buffer_json_member_add_boolean(w->response.data, "anonymous_statistics", netdata_anonymous_statistics_enabled);
191
192
buffer_json_member_add_array(w->response.data, "nodes");
193
- RRDHOST *h;
194
- dfe_start_read(rrdhost_root_index, h) {
193
+ {
194
buffer_json_add_array_item_object(w->response.data);
196
- buffer_json_member_add_string(w->response.data, "machine_guid", h->machine_guid);
197
-
198
- if(h->node_id)
199
- buffer_json_member_add_uuid(w->response.data, "node_id", h->node_id);
200
-
201
- buffer_json_member_add_string(w->response.data, "hostname", rrdhost_registry_hostname(h));
202
- buffer_json_object_close(w->response.data);
195
+ buffer_json_member_add_string(w->response.data, "machine_guid", host->machine_guid);
196
+ buffer_json_member_add_string(w->response.data, "hostname", rrdhost_registry_hostname(host));
197
}
204
- dfe_done(h);
198
+ buffer_json_object_close(w->response.data); // nodes
199
+
200
+// RRDHOST *h;
201
+// dfe_start_read(rrdhost_root_index, h) {
202
+// buffer_json_add_array_item_object(w->response.data);
203
+// buffer_json_member_add_string(w->response.data, "machine_guid", h->machine_guid);
204
+//
205
+// if(h->node_id)
206
+// buffer_json_member_add_uuid(w->response.data, "node_id", h->node_id);
207
+//
208
+// buffer_json_member_add_string(w->response.data, "hostname", rrdhost_registry_hostname(h));
209
+// buffer_json_object_close(w->response.data);
210
+// }
211
+// dfe_done(h);
212
buffer_json_array_close(w->response.data);
213
214
registry_json_footer(w);
tests/ebpf/ebpf_thread_function.sh
deleted
-52
@@ -1,52 +0,0 @@
1
-#!/bin/bash
2
-
3
-netdata_ebpf_test_functions() {
4
- echo "QUERYING: ${1}"
5
- curl -k -o /tmp/ebpf_netdata_test_functions.txt "${1}"
6
- TEST=$?
7
- if [ $TEST -ne 0 ]; then
8
- echo "Cannot request run a for ${1}. See '/tmp/ebpf_netdata_test_functions.txt' for more details."
9
- exit 1
10
- fi
11
-
12
- grep "${2}" /tmp/ebpf_netdata_test_functions.txt >/dev/null
13
- TEST=$?
14
- if [ $TEST -ne 0 ]; then
15
- echo "Cannot find ${2} in the output. See '/tmp/ebpf_netdata_test_functions.txt' for more details.."
16
- exit 1
17
- fi
18
-
19
- rm /tmp/ebpf_netdata_test_functions.txt
20
-}
21
-
22
-MURL="http://127.0.0.1:19999"
23
-INTERVAL=60
24
-
25
-if [ -n "$1" ]; then
26
- MURL="$1"
27
-fi
28
-
29
-# Check function loaded
30
-netdata_ebpf_test_functions "${MURL}/api/v1/functions" "ebpf_thread"
31
-
32
-# Check function help
33
-netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20help" "allows user to control eBPF threads"
34
-
35
-#Test default request
36
-netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread" "columns"
37
-
38
-#Test thread requests . The mdflush is not enabled, because it is not present in all distributions by default.
39
-#Socket is not in the list, because it will have a complete refactory with next PR
40
-for THREAD in "cachestat" "dc" "disk" "fd" "filesystem" "hardirq" "mount" "oomkill" "process" "shm" "softirq" "sync" "swap" "vfs" ;
41
-do
42
- echo "TESTING ${THREAD}"
43
- netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20enable:${THREAD}:${INTERVAL}%20thread:${THREAD}"
44
- sleep 17
45
- netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20thread:${THREAD}" "running"
46
- sleep 17
47
- netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20disable:${THREAD}"
48
- sleep 6
49
- netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20thread:${THREAD}" "stopped"
50
- sleep 6
51
-done
52
-