@cryptotaxi247 / netdata-1 / commits / f387a29ca

Session claim id in docker (#20240)

Stelios Fragkakis committed May 7, 2025 at 09:53 UTC f387a29cacc0d7ccf2ddc38be518a070a60d2fad
3 files changed +13 -1
src/database/rrdhost-system-info.c
+7
@@ -677,3 +677,10 @@ bool get_daemon_status_fields_from_system_info(DAEMON_STATUS_FILE *ds) {
677
678 return true;
679 }
680 +
681 +bool localhost_is_docker() {
682 + if (localhost && localhost->system_info) {
683 + return (localhost->system_info->container && strcmp(localhost->system_info->container, "docker") == 0);
684 + }
685 + return false;
686 +};
\ No newline at end of file
src/database/rrdhost-system-info.h
+2
@@ -102,4 +102,6 @@ void rrdhost_system_info_to_streaming_function_array(BUFFER *wb, struct rrdhost_
102 bool get_daemon_status_fields_from_system_info(DAEMON_STATUS_FILE *ds);
103 void rrdhost_system_info_swap(struct rrdhost_system_info *a, struct rrdhost_system_info *b);
104
105 +bool localhost_is_docker();
106 +
107 #endif //NETDATA_RRDHOST_SYSTEM_INFO_H
src/web/api/v2/api_v2_claim.c
+4 -1
@@ -120,7 +120,10 @@ static void claim_add_user_info_command(BUFFER *wb) {
120 os_message = "We need to verify this Windows server is yours. So, open a Command Prompt on this server to run the command. It will give you a UUID. Copy and paste this UUID to this box:";
121 #else
122 os_filename = filename;
123 - os_prefix = "sudo cat";
123 + if (localhost_is_docker())
124 + os_prefix = "docker exec netdata cat";
125 + else
126 + os_prefix = "sudo cat";
127 os_message = "We need to verify this server is yours. SSH to this server and run this command. It will give you a UUID. Copy and paste this UUID to this box:";
128 #endif
129