@cryptotaxi247 / netdata-1 / commits / 59394b5f9

Add hop count for children (#11311)

Stelios Fragkakis committed Jul 7, 2021 at 13:23 UTC 59394b5f9d8891cb59c42ac87fd8f0d41b28db94
5 files changed +9 -4
daemon/main.c
+1
@@ -1230,6 +1230,7 @@ int main(int argc, char **argv) {
1230 netdata_anonymous_statistics_enabled=-1;
1231 struct rrdhost_system_info *system_info = calloc(1, sizeof(struct rrdhost_system_info));
1232 get_system_info(system_info);
1233 + system_info->hops = 0;
1234
1235 if(rrd_init(netdata_configured_hostname, system_info))
1236 fatal("Cannot initialize localhost instance with name '%s'.", netdata_configured_hostname);
database/rrd.h
+1
@@ -740,6 +740,7 @@ struct rrdhost_system_info {
740 char *container;
741 char *container_detection;
742 char *is_k8s_node;
743 + uint16_t hops;
744 };
745
746 struct rrdhost {
streaming/rrdpush.c
+3 -1
@@ -471,7 +471,7 @@ int rrdpush_receiver_thread_spawn(struct web_client *w, char *url) {
471 char buf[GUID_LEN + 1];
472
473 struct rrdhost_system_info *system_info = callocz(1, sizeof(struct rrdhost_system_info));
474 -
474 + system_info->hops = 1;
475 while(url) {
476 char *value = mystrsep(&url, "&");
477 if(!value || !*value) continue;
@@ -498,6 +498,8 @@ int rrdpush_receiver_thread_spawn(struct web_client *w, char *url) {
498 abbrev_timezone = value;
499 else if(!strcmp(name, "utc_offset"))
500 utc_offset = (int32_t)strtol(value, NULL, 0);
501 + else if(!strcmp(name, "hops"))
502 + system_info->hops = (uint16_t) strtoul(value, NULL, 0);
503 else if(!strcmp(name, "tags"))
504 tags = value;
505 else if(!strcmp(name, "ver"))
streaming/sender.c
+2 -1
@@ -214,7 +214,7 @@ static int rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_po
214
215 char http[HTTP_HEADER_SIZE + 1];
216 int eol = snprintfz(http, HTTP_HEADER_SIZE,
217 - "STREAM key=%s&hostname=%s&registry_hostname=%s&machine_guid=%s&update_every=%d&os=%s&timezone=%s&abbrev_timezone=%s&utc_offset=%d&tags=%s&ver=%u"
217 + "STREAM key=%s&hostname=%s&registry_hostname=%s&machine_guid=%s&update_every=%d&os=%s&timezone=%s&abbrev_timezone=%s&utc_offset=%d&hops=%d&tags=%s&ver=%u"
218 "&NETDATA_SYSTEM_OS_NAME=%s"
219 "&NETDATA_SYSTEM_OS_ID=%s"
220 "&NETDATA_SYSTEM_OS_ID_LIKE=%s"
@@ -252,6 +252,7 @@ static int rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_po
252 , host->timezone
253 , host->abbrev_timezone
254 , host->utc_offset
255 + , host->system_info->hops + 1
256 , (host->tags) ? host->tags : ""
257 , STREAMING_PROTOCOL_CURRENT_VERSION
258 , se.os_name
web/api/web_api_v1.c
+2 -2
@@ -867,8 +867,8 @@ static inline void web_client_api_request_v1_info_mirrored_hosts(BUFFER *wb) {
867
868 netdata_mutex_lock(&host->receiver_lock);
869 buffer_sprintf(
870 - wb, "\t\t{ \"guid\": \"%s\", \"reachable\": %s, \"claim_id\": ", host->machine_guid,
871 - (host->receiver || host == localhost) ? "true" : "false");
870 + wb, "\t\t{ \"guid\": \"%s\", \"reachable\": %s, \"hops\": %d, \"claim_id\": ", host->machine_guid,
871 + (host->receiver || host == localhost) ? "true" : "false", host->system_info ? host->system_info->hops : (host == localhost) ? 0 : 1);
872 netdata_mutex_unlock(&host->receiver_lock);
873
874 rrdhost_aclk_state_lock(host);