@cryptotaxi247 / netdata-1 / commits / b846b5a9a

Sends netdata.public.unique.id (machine GUID) with claim (#9574)

send mguid to the cloud

Timotej S committed Jul 23, 2020 at 16:19 UTC b846b5a9a3f9a1ffea01ef17f50710974ccfd7f5
2 files changed +9 -1
claim/claim.c
+1
@@ -25,6 +25,7 @@ static char *claiming_errors[] = {
25 "Internal Server Error", // 15
26 "Gateway Timeout", // 16
27 "Service Unavailable" // 17
28 + "Agent Unique Id Not Readable" // 18
29 };
30 static netdata_mutex_t claim_mutex = NETDATA_MUTEX_INITIALIZER;
31 static char *claimed_id = NULL;
claim/netdata-claim.sh.in
+8 -1
@@ -83,6 +83,8 @@ ERROR_MESSAGES[16]="Gateway Timeout"
83 ERROR_KEYS[17]="ErrServiceUnavailable"
84 ERROR_MESSAGES[17]="Service Unavailable"
85
86 +# Exit code: 18 - Agent unique id is not generated yet.
87 +
88 get_config_value() {
89 conf_file="${1}"
90 section="${2}"
@@ -142,6 +144,10 @@ NETDATA_USER=$(get_config_value netdata global "run as user")
144 # get the MACHINE_GUID by default
145 if [ -r "${MACHINE_GUID_FILE}" ]; then
146 ID="$(cat "${MACHINE_GUID_FILE}")"
147 + MGUID=$ID
148 +else
149 + echo >&2 "netdata.public.unique.id is not generated yet or not readable. Please run agent at least once before attempting to claim. Agent generates this file on first startup. If the ID is generated already make sure you have rights to read it (Filename: ${MACHINE_GUID_FILE})."
150 + exit 18
151 fi
152
153 # get token from file
@@ -236,7 +242,8 @@ cat > "${CLAIMING_DIR}/tmpin.txt" <<EMBED_JSON
242 },
243 "token": "$TOKEN",
244 "rooms" : [ $ROOMS ],
239 - "publicKey" : "$KEY"
245 + "publicKey" : "$KEY",
246 + "mGUID" : "$MGUID"
247 }
248 EMBED_JSON
249