summaryrefslogtreecommitdiffstats
path: root/claim
diff options
context:
space:
mode:
Diffstat (limited to 'claim')
-rw-r--r--claim/README.md18
-rw-r--r--claim/claim.c50
-rwxr-xr-xclaim/netdata-claim.sh.in2
3 files changed, 42 insertions, 28 deletions
diff --git a/claim/README.md b/claim/README.md
index fed37018..5b15a6c1 100644
--- a/claim/README.md
+++ b/claim/README.md
@@ -69,7 +69,7 @@ When coming from the [Nodes tab](https://github.com/netdata/netdata/blob/master/
If you want to connect a node that is running on a Linux environment, the script that will be provided to you by Netdata Cloud is the [kickstart](https://github.com/netdata/netdata/blob/master/packaging/installer/README.md#automatic-one-line-installation-script) which will install the Netdata Agent on your node, if it isn't already installed, and connect the node to Netdata Cloud. It should be similar to:
```bash
-wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh --claim-token TOKEN --claim-rooms ROOM1,ROOM2 --claim-url https://api.netdata.cloud
+wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh --claim-token TOKEN --claim-rooms ROOM1,ROOM2 --claim-url https://app.netdata.cloud
```
The script should return `Agent was successfully claimed.`. If the connecting to Netdata Cloud process returns errors, or if you don't see
@@ -98,7 +98,7 @@ The default user is `netdata`. Yours may be different, so pay attention to the o
and run the script.
```bash
-wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh --claim-token TOKEN --claim-rooms ROOM1,ROOM2 --claim-url https://api.netdata.cloud
+wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh --claim-token TOKEN --claim-rooms ROOM1,ROOM2 --claim-url https://app.netdata.cloud
```
### Connect an agent running in Docker
@@ -209,7 +209,7 @@ docker run -d --name=netdata \
--cap-add SYS_PTRACE \
--security-opt apparmor=unconfined \
-e NETDATA_CLAIM_TOKEN=TOKEN \
- -e NETDATA_CLAIM_URL="https://api.netdata.cloud" \
+ -e NETDATA_CLAIM_URL="https://app.netdata.cloud" \
-e NETDATA_CLAIM_ROOMS=ROOM1,ROOM2 \
-e NETDATA_CLAIM_PROXY=PROXY \
netdata/netdata
@@ -254,7 +254,7 @@ services:
- /etc/os-release:/host/etc/os-release:ro
environment:
- NETDATA_CLAIM_TOKEN=TOKEN
- - NETDATA_CLAIM_URL="https://api.netdata.cloud"
+ - NETDATA_CLAIM_URL="https://app.netdata.cloud"
- NETDATA_CLAIM_ROOMS=ROOM1,ROOM2
volumes:
@@ -275,7 +275,7 @@ Connect a _running Netdata Agent container_, where you don't want to recreate th
`netdata` with the name of your running container:
```bash
-docker exec -it netdata netdata-claim.sh -token=TOKEN -rooms=ROOM1,ROOM2 -url=https://api.netdata.cloud
+docker exec -it netdata netdata-claim.sh -token=TOKEN -rooms=ROOM1,ROOM2 -url=https://app.netdata.cloud
```
The values for `ROOM1,ROOM2` can be found by by going to Netdata Cloud, clicking the **Nodes** tab, clicking **Connect Nodes**, selecting **Docker**, and copying the `rooms=` value in the command provided.
@@ -288,7 +288,7 @@ you don't see the node in your Space after 60 seconds, see the [troubleshooting
To connect a node that is running on a macOS environment the script that will be provided to you by Netdata Cloud is the [kickstart](https://github.com/netdata/netdata/blob/master/packaging/installer/methods/macos.md#install-netdata-with-our-automatic-one-line-installation-script) which will install the Netdata Agent on your node, if it isn't already installed, and connect the node to Netdata Cloud. It should be similar to:
```bash
-curl https://my-netdata.io/kickstart.sh > /tmp/netdata-kickstart.sh && sh /tmp/netdata-kickstart.sh --install-prefix /usr/local/ --claim-token TOKEN --claim-rooms ROOM1,ROOM2 --claim-url https://api.netdata.cloud
+curl https://my-netdata.io/kickstart.sh > /tmp/netdata-kickstart.sh && sh /tmp/netdata-kickstart.sh --install-prefix /usr/local/ --claim-token TOKEN --claim-rooms ROOM1,ROOM2 --claim-url https://app.netdata.cloud
```
The script should return `Agent was successfully claimed.`. If the connecting to Netdata Cloud process returns errors, or if you don't see
@@ -329,7 +329,7 @@ You can now move on to connecting. When you connect with the [kickstart](https:/
append the same proxy setting you added to `netdata.conf`.
```bash
-wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh --claim-token TOKEN --claim-rooms ROOM1,ROOM2 --claim-url https://api.netdata.cloud --claim-proxy http://[user:pass@]host:ip
+wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh --claim-token TOKEN --claim-rooms ROOM1,ROOM2 --claim-url https://app.netdata.cloud --claim-proxy http://[user:pass@]host:ip
```
Hit **Enter**. The script should return `Agent was successfully claimed.`. If the connecting to Netdata Cloud process returns errors, or if
@@ -566,7 +566,7 @@ using the [ACLK](https://github.com/netdata/netdata/blob/master/aclk/README.md).
| setting | default | info |
|:-------------- |:------------------------- |:-------------------------------------------------------------------------------------------------------------------------------------- |
-| cloud base url | <https://api.netdata.cloud> | The URL for the Netdata Cloud web application. You should not change this. If you want to disable Cloud, change the `enabled` setting. |
+| cloud base url | <https://app.netdata.cloud> | The URL for the Netdata Cloud web application. You should not change this. If you want to disable Cloud, change the `enabled` setting. |
| enabled | yes | The runtime option to disable the [Agent-Cloud link](https://github.com/netdata/netdata/blob/master/aclk/README.md) and prevent your Agent from connecting to Netdata Cloud. |
### Claiming script
@@ -580,7 +580,7 @@ using `sudo`, or as the user running the Agent (typically `netdata`), and passin
-rooms=ROOM1,ROOM2,...
where ROOMX is the War Room this node should be added to. This list is optional.
-url=URL_BASE
- where URL_BASE is the Netdata Cloud endpoint base URL. By default, this is https://api.netdata.cloud.
+ where URL_BASE is the Netdata Cloud endpoint base URL. By default, this is https://app.netdata.cloud.
-id=AGENT_ID
where AGENT_ID is the unique identifier of the Agent. This is the Agent's MACHINE_GUID by default.
-hostname=HOSTNAME
diff --git a/claim/claim.c b/claim/claim.c
index a30fd0da..d81440d2 100644
--- a/claim/claim.c
+++ b/claim/claim.c
@@ -57,7 +57,8 @@ CLAIM_AGENT_RESPONSE claim_agent(const char *claiming_arguments, bool force, con
#ifndef DISABLE_CLOUD
int exit_code;
pid_t command_pid;
- char command_buffer[CLAIMING_COMMAND_LENGTH + 1];
+ char command_exec_buffer[CLAIMING_COMMAND_LENGTH + 1];
+ char command_line_buffer[CLAIMING_COMMAND_LENGTH + 1];
FILE *fp_child_output, *fp_child_input;
// This is guaranteed to be set early in main via post_conf_load()
@@ -76,42 +77,55 @@ CLAIM_AGENT_RESPONSE claim_agent(const char *claiming_arguments, bool force, con
if (proxy_type == PROXY_TYPE_SOCKS5 || proxy_type == PROXY_TYPE_HTTP)
snprintf(proxy_flag, CLAIMING_PROXY_LENGTH, "-proxy=\"%s\"", proxy_str);
- snprintfz(command_buffer,
+ snprintfz(command_exec_buffer, CLAIMING_COMMAND_LENGTH,
+ "exec \"%s%snetdata-claim.sh\"",
+ netdata_exe_path[0] ? netdata_exe_path : "",
+ netdata_exe_path[0] ? "/" : ""
+ );
+
+ snprintfz(command_line_buffer,
CLAIMING_COMMAND_LENGTH,
- "exec netdata-claim.sh %s -hostname=%s -id=%s -url=%s -noreload %s",
+ "%s %s -hostname=%s -id=%s -url=%s -noreload %s",
+ command_exec_buffer,
proxy_flag,
netdata_configured_hostname,
localhost->machine_guid,
cloud_base_url,
claiming_arguments);
- netdata_log_info("Executing agent claiming command 'netdata-claim.sh'");
- fp_child_output = netdata_popen(command_buffer, &command_pid, &fp_child_input);
+ netdata_log_info("Executing agent claiming command: %s", command_exec_buffer);
+ fp_child_output = netdata_popen(command_line_buffer, &command_pid, &fp_child_input);
if(!fp_child_output) {
- netdata_log_error("Cannot popen(\"%s\").", command_buffer);
+ netdata_log_error("Cannot popen(\"%s\").", command_exec_buffer);
return CLAIM_AGENT_CANNOT_EXECUTE_CLAIM_SCRIPT;
}
- netdata_log_info("Waiting for claiming command to finish.");
- while (fgets(command_buffer, CLAIMING_COMMAND_LENGTH, fp_child_output) != NULL) {;}
+
+ netdata_log_info("Waiting for claiming command '%s' to finish.", command_exec_buffer);
+ char read_buffer[100 + 1];
+ while (fgets(read_buffer, 100, fp_child_output) != NULL) {;}
+
exit_code = netdata_pclose(fp_child_input, fp_child_output, command_pid);
- netdata_log_info("Agent claiming command returned with code %d", exit_code);
+
+ netdata_log_info("Agent claiming command '%s' returned with code %d", command_exec_buffer, exit_code);
if (0 == exit_code) {
load_claiming_state();
return CLAIM_AGENT_OK;
}
if (exit_code < 0) {
- netdata_log_error("Agent claiming command failed to complete its run.");
+ netdata_log_error("Agent claiming command '%s' failed to complete its run", command_exec_buffer);
return CLAIM_AGENT_CLAIM_SCRIPT_FAILED;
}
errno = 0;
unsigned maximum_known_exit_code = sizeof(claiming_errors) / sizeof(claiming_errors[0]) - 1;
if ((unsigned)exit_code > maximum_known_exit_code) {
- netdata_log_error("Agent failed to be claimed with an unknown error.");
+ netdata_log_error("Agent failed to be claimed with an unknown error. Cmd: '%s'", command_exec_buffer);
return CLAIM_AGENT_CLAIM_SCRIPT_RETURNED_INVALID_CODE;
}
- netdata_log_error("Agent failed to be claimed with the following error message:");
+ netdata_log_error("Agent failed to be claimed using the command '%s' with the following error message:",
+ command_exec_buffer);
+
netdata_log_error("\"%s\"", claiming_errors[exit_code]);
if(msg) *msg = claiming_errors[exit_code];
@@ -342,7 +356,7 @@ int api_v2_claim(struct web_client *w, char *url) {
BUFFER *wb = w->response.data;
buffer_flush(wb);
- buffer_json_initialize(wb, "\"", "\"", 0, true, false);
+ buffer_json_initialize(wb, "\"", "\"", 0, true, BUFFER_JSON_OPTIONS_DEFAULT);
time_t now_s = now_realtime_sec();
CLOUD_STATUS status = buffer_json_cloud_status(wb, now_s);
@@ -409,12 +423,12 @@ int api_v2_claim(struct web_client *w, char *url) {
int ms = 0;
do {
status = cloud_status();
- if (status == CLOUD_STATUS_ONLINE)
+ if (status == CLOUD_STATUS_ONLINE && __atomic_load_n(&localhost->node_id, __ATOMIC_RELAXED))
break;
- sleep_usec(100 * USEC_PER_MS);
- ms += 100;
- } while (ms < 5000);
+ sleep_usec(50 * USEC_PER_MS);
+ ms += 50;
+ } while (ms < 10000);
}
break;
@@ -448,7 +462,7 @@ int api_v2_claim(struct web_client *w, char *url) {
// our status may have changed
// refresh the status in our output
buffer_flush(wb);
- buffer_json_initialize(wb, "\"", "\"", 0, true, false);
+ buffer_json_initialize(wb, "\"", "\"", 0, true, BUFFER_JSON_OPTIONS_DEFAULT);
now_s = now_realtime_sec();
buffer_json_cloud_status(wb, now_s);
diff --git a/claim/netdata-claim.sh.in b/claim/netdata-claim.sh.in
index 43040e31..cc6c1093 100755
--- a/claim/netdata-claim.sh.in
+++ b/claim/netdata-claim.sh.in
@@ -136,7 +136,7 @@ MACHINE_GUID_FILE="@registrydir_POST@/netdata.public.unique.id"
CLAIMING_DIR="${NETDATA_VARLIB_DIR}/cloud.d"
TOKEN="unknown"
URL_BASE=$(get_config_value cloud global "cloud base url")
-[ -z "$URL_BASE" ] && URL_BASE="https://api.netdata.cloud" # Cover post-install with --dont-start
+[ -z "$URL_BASE" ] && URL_BASE="https://app.netdata.cloud" # Cover post-install with --dont-start
ID="unknown"
ROOMS=""
[ -z "$HOSTNAME" ] && HOSTNAME=$(hostname)