diff options
-rw-r--r-- | daemon/main.c | 1 | ||||
-rw-r--r-- | database/rrd.h | 1 | ||||
-rw-r--r-- | streaming/rrdpush.c | 4 | ||||
-rw-r--r-- | streaming/sender.c | 3 | ||||
-rw-r--r-- | web/api/web_api_v1.c | 4 |
5 files changed, 9 insertions, 4 deletions
diff --git a/daemon/main.c b/daemon/main.c index e040d70b3b..c0ba3cb105 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -1230,6 +1230,7 @@ int main(int argc, char **argv) { netdata_anonymous_statistics_enabled=-1; struct rrdhost_system_info *system_info = calloc(1, sizeof(struct rrdhost_system_info)); get_system_info(system_info); + system_info->hops = 0; if(rrd_init(netdata_configured_hostname, system_info)) fatal("Cannot initialize localhost instance with name '%s'.", netdata_configured_hostname); diff --git a/database/rrd.h b/database/rrd.h index 6179ec5574..5ea26caafe 100644 --- a/database/rrd.h +++ b/database/rrd.h @@ -740,6 +740,7 @@ struct rrdhost_system_info { char *container; char *container_detection; char *is_k8s_node; + uint16_t hops; }; struct rrdhost { diff --git a/streaming/rrdpush.c b/streaming/rrdpush.c index 854336e118..038383b55b 100644 --- a/streaming/rrdpush.c +++ b/streaming/rrdpush.c @@ -471,7 +471,7 @@ int rrdpush_receiver_thread_spawn(struct web_client *w, char *url) { char buf[GUID_LEN + 1]; struct rrdhost_system_info *system_info = callocz(1, sizeof(struct rrdhost_system_info)); - + system_info->hops = 1; while(url) { char *value = mystrsep(&url, "&"); if(!value || !*value) continue; @@ -498,6 +498,8 @@ int rrdpush_receiver_thread_spawn(struct web_client *w, char *url) { abbrev_timezone = value; else if(!strcmp(name, "utc_offset")) utc_offset = (int32_t)strtol(value, NULL, 0); + else if(!strcmp(name, "hops")) + system_info->hops = (uint16_t) strtoul(value, NULL, 0); else if(!strcmp(name, "tags")) tags = value; else if(!strcmp(name, "ver")) diff --git a/streaming/sender.c b/streaming/sender.c index d25001d355..60cf3f2445 100644 --- a/streaming/sender.c +++ b/streaming/sender.c @@ -214,7 +214,7 @@ static int rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_po char http[HTTP_HEADER_SIZE + 1]; int eol = snprintfz(http, HTTP_HEADER_SIZE, - "STREAM key=%s&hostname=%s®istry_hostname=%s&machine_guid=%s&update_every=%d&os=%s&timezone=%s&abbrev_timezone=%s&utc_offset=%d&tags=%s&ver=%u" + "STREAM key=%s&hostname=%s®istry_hostname=%s&machine_guid=%s&update_every=%d&os=%s&timezone=%s&abbrev_timezone=%s&utc_offset=%d&hops=%d&tags=%s&ver=%u" "&NETDATA_SYSTEM_OS_NAME=%s" "&NETDATA_SYSTEM_OS_ID=%s" "&NETDATA_SYSTEM_OS_ID_LIKE=%s" @@ -252,6 +252,7 @@ static int rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_po , host->timezone , host->abbrev_timezone , host->utc_offset + , host->system_info->hops + 1 , (host->tags) ? host->tags : "" , STREAMING_PROTOCOL_CURRENT_VERSION , se.os_name diff --git a/web/api/web_api_v1.c b/web/api/web_api_v1.c index c58a86af0f..f0a3ea146c 100644 --- a/web/api/web_api_v1.c +++ b/web/api/web_api_v1.c @@ -867,8 +867,8 @@ static inline void web_client_api_request_v1_info_mirrored_hosts(BUFFER *wb) { netdata_mutex_lock(&host->receiver_lock); buffer_sprintf( - wb, "\t\t{ \"guid\": \"%s\", \"reachable\": %s, \"claim_id\": ", host->machine_guid, - (host->receiver || host == localhost) ? "true" : "false"); + wb, "\t\t{ \"guid\": \"%s\", \"reachable\": %s, \"hops\": %d, \"claim_id\": ", host->machine_guid, + (host->receiver || host == localhost) ? "true" : "false", host->system_info ? host->system_info->hops : (host == localhost) ? 0 : 1); netdata_mutex_unlock(&host->receiver_lock); rrdhost_aclk_state_lock(host); |