summaryrefslogtreecommitdiffstats
path: root/claim
diff options
context:
space:
mode:
authorTimotej S <6674623+underhood@users.noreply.github.com>2020-07-23 16:19:45 +0200
committerGitHub <noreply@github.com>2020-07-23 16:19:45 +0200
commitb846b5a9a3f9a1ffea01ef17f50710974ccfd7f5 (patch)
treea09c7606f8f570914673cba741eda1974d34e59f /claim
parent219895300847a6347a1f4b8d82ad04455a682b03 (diff)
Sends netdata.public.unique.id (machine GUID) with claim (#9574)
send mguid to the cloud
Diffstat (limited to 'claim')
-rw-r--r--claim/claim.c1
-rwxr-xr-xclaim/netdata-claim.sh.in9
2 files changed, 9 insertions, 1 deletions
diff --git a/claim/claim.c b/claim/claim.c
index 59c824235d..143d30d829 100644
--- a/claim/claim.c
+++ b/claim/claim.c
@@ -25,6 +25,7 @@ static char *claiming_errors[] = {
"Internal Server Error", // 15
"Gateway Timeout", // 16
"Service Unavailable" // 17
+ "Agent Unique Id Not Readable" // 18
};
static netdata_mutex_t claim_mutex = NETDATA_MUTEX_INITIALIZER;
static char *claimed_id = NULL;
diff --git a/claim/netdata-claim.sh.in b/claim/netdata-claim.sh.in
index 098b1a216d..43f663f8b7 100755
--- a/claim/netdata-claim.sh.in
+++ b/claim/netdata-claim.sh.in
@@ -83,6 +83,8 @@ ERROR_MESSAGES[16]="Gateway Timeout"
ERROR_KEYS[17]="ErrServiceUnavailable"
ERROR_MESSAGES[17]="Service Unavailable"
+# Exit code: 18 - Agent unique id is not generated yet.
+
get_config_value() {
conf_file="${1}"
section="${2}"
@@ -142,6 +144,10 @@ NETDATA_USER=$(get_config_value netdata global "run as user")
# get the MACHINE_GUID by default
if [ -r "${MACHINE_GUID_FILE}" ]; then
ID="$(cat "${MACHINE_GUID_FILE}")"
+ MGUID=$ID
+else
+ 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})."
+ exit 18
fi
# get token from file
@@ -236,7 +242,8 @@ cat > "${CLAIMING_DIR}/tmpin.txt" <<EMBED_JSON
},
"token": "$TOKEN",
"rooms" : [ $ROOMS ],
- "publicKey" : "$KEY"
+ "publicKey" : "$KEY",
+ "mGUID" : "$MGUID"
}
EMBED_JSON