summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkos Fountoulakis <44345837+mfundul@users.noreply.github.com>2020-05-12 20:08:29 +0300
committerGitHub <noreply@github.com>2020-05-12 20:08:29 +0300
commit26a113a8357e1db70e1f92a1b42fff581b8e9108 (patch)
treedc9f952933248bbff6eb39f7d41f614929ca81d6
parent3c81dfcac40de3a3b9d052a8da87acf636743a53 (diff)
Restore old semantics of "netdata -W set" command (#8987)
-rw-r--r--claim/README.md2
-rw-r--r--daemon/main.c30
2 files changed, 31 insertions, 1 deletions
diff --git a/claim/README.md b/claim/README.md
index 5fa1b30bcc..6dda79f1f5 100644
--- a/claim/README.md
+++ b/claim/README.md
@@ -121,7 +121,7 @@ docker run -d --name=netdata \
--cap-add SYS_PTRACE \
--security-opt apparmor=unconfined \
netdata/netdata \
- /usr/sbin/netdata -D -W set cloud global enabled true -W set cloud global "cloud base url" "https://app.netdata.cloud" -W "claim -token=TOKEN -rooms=ROOM1,ROOM2 -url=https://app.netdata.cloud"
+ /usr/sbin/netdata -D -W set2 cloud global enabled true -W set2 cloud global "cloud base url" "https://app.netdata.cloud" -W "claim -token=TOKEN -rooms=ROOM1,ROOM2 -url=https://app.netdata.cloud"
```
The container runs in detached mode, so you won't see any output. If the node does not appear in your Space, you can run
diff --git a/daemon/main.c b/daemon/main.c
index ae7bba61fa..098ddbac5b 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -1086,6 +1086,36 @@ int main(int argc, char **argv) {
debug_flags = strtoull(optarg, NULL, 0);
}
else if(strcmp(optarg, "set") == 0) {
+ if(optind + 3 > argc) {
+ fprintf(stderr, "%s", "\nUSAGE: -W set 'section' 'key' 'value'\n\n"
+ " Overwrites settings of netdata.conf.\n"
+ "\n"
+ " These options interact with: -c netdata.conf\n"
+ " If -c netdata.conf is given on the command line,\n"
+ " before -W set... the user may overwrite command\n"
+ " line parameters at netdata.conf\n"
+ " If -c netdata.conf is given after (or missing)\n"
+ " -W set... the user cannot overwrite the command line\n"
+ " parameters."
+ "\n"
+ );
+ return 1;
+ }
+ const char *section = argv[optind];
+ const char *key = argv[optind + 1];
+ const char *value = argv[optind + 2];
+ optind += 3;
+
+ // set this one as the default
+ // only if it is not already set in the config file
+ // so the caller can use -c netdata.conf before or
+ // after this parameter to prevent or allow overwriting
+ // variables at netdata.conf
+ config_set_default(section, key, value);
+
+ // fprintf(stderr, "SET section '%s', key '%s', value '%s'\n", section, key, value);
+ }
+ else if(strcmp(optarg, "set2") == 0) {
if(optind + 4 > argc) {
fprintf(stderr, "%s", "\nUSAGE: -W set 'conf_file' 'section' 'key' 'value'\n\n"
" Overwrites settings of netdata.conf or cloud.conf\n"