0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-28 14:42:31 +00:00

Revert "dont add all nodes to registry action hello" ()

Revert "dont add all nodes to registry action hello ()"

This reverts commit 76d10ab250.
This commit is contained in:
Costa Tsaousis 2023-07-13 22:48:29 +03:00 committed by GitHub
parent 76d10ab250
commit 7519f01891
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 18 deletions

View file

@ -58,7 +58,7 @@ static inline void registry_set_person_cookie(struct web_client *w, REGISTRY_PER
static inline void registry_json_header(RRDHOST *host, struct web_client *w, const char *action, const char *status) {
buffer_flush(w->response.data);
w->response.data->content_type = CT_APPLICATION_JSON;
buffer_json_initialize(w->response.data, "\"", "\"", 0, true, true);
buffer_json_initialize(w->response.data, "\"", "\"", 0, true, false);
buffer_json_member_add_string(w->response.data, "action", action);
buffer_json_member_add_string(w->response.data, "status", status);
buffer_json_member_add_string(w->response.data, "hostname", rrdhost_registry_hostname(host));
@ -190,25 +190,18 @@ int registry_request_hello_json(RRDHOST *host, struct web_client *w) {
buffer_json_member_add_boolean(w->response.data, "anonymous_statistics", netdata_anonymous_statistics_enabled);
buffer_json_member_add_array(w->response.data, "nodes");
{
RRDHOST *h;
dfe_start_read(rrdhost_root_index, h) {
buffer_json_add_array_item_object(w->response.data);
buffer_json_member_add_string(w->response.data, "machine_guid", host->machine_guid);
buffer_json_member_add_string(w->response.data, "hostname", rrdhost_registry_hostname(host));
}
buffer_json_object_close(w->response.data); // nodes
buffer_json_member_add_string(w->response.data, "machine_guid", h->machine_guid);
// RRDHOST *h;
// dfe_start_read(rrdhost_root_index, h) {
// buffer_json_add_array_item_object(w->response.data);
// buffer_json_member_add_string(w->response.data, "machine_guid", h->machine_guid);
//
// if(h->node_id)
// buffer_json_member_add_uuid(w->response.data, "node_id", h->node_id);
//
// buffer_json_member_add_string(w->response.data, "hostname", rrdhost_registry_hostname(h));
// buffer_json_object_close(w->response.data);
// }
// dfe_done(h);
if(h->node_id)
buffer_json_member_add_uuid(w->response.data, "node_id", h->node_id);
buffer_json_member_add_string(w->response.data, "hostname", rrdhost_registry_hostname(h));
buffer_json_object_close(w->response.data);
}
dfe_done(h);
buffer_json_array_close(w->response.data);
registry_json_footer(w);

View file

@ -0,0 +1,52 @@
#!/bin/bash
netdata_ebpf_test_functions() {
echo "QUERYING: ${1}"
curl -k -o /tmp/ebpf_netdata_test_functions.txt "${1}"
TEST=$?
if [ $TEST -ne 0 ]; then
echo "Cannot request run a for ${1}. See '/tmp/ebpf_netdata_test_functions.txt' for more details."
exit 1
fi
grep "${2}" /tmp/ebpf_netdata_test_functions.txt >/dev/null
TEST=$?
if [ $TEST -ne 0 ]; then
echo "Cannot find ${2} in the output. See '/tmp/ebpf_netdata_test_functions.txt' for more details.."
exit 1
fi
rm /tmp/ebpf_netdata_test_functions.txt
}
MURL="http://127.0.0.1:19999"
INTERVAL=60
if [ -n "$1" ]; then
MURL="$1"
fi
# Check function loaded
netdata_ebpf_test_functions "${MURL}/api/v1/functions" "ebpf_thread"
# Check function help
netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20help" "allows user to control eBPF threads"
#Test default request
netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread" "columns"
#Test thread requests . The mdflush is not enabled, because it is not present in all distributions by default.
#Socket is not in the list, because it will have a complete refactory with next PR
for THREAD in "cachestat" "dc" "disk" "fd" "filesystem" "hardirq" "mount" "oomkill" "process" "shm" "softirq" "sync" "swap" "vfs" ;
do
echo "TESTING ${THREAD}"
netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20enable:${THREAD}:${INTERVAL}%20thread:${THREAD}"
sleep 17
netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20thread:${THREAD}" "running"
sleep 17
netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20disable:${THREAD}"
sleep 6
netdata_ebpf_test_functions "${MURL}/api/v1/function?function=ebpf_thread%20thread:${THREAD}" "stopped"
sleep 6
done