@cryptotaxi247 / netdata-1 / commits / 26a113a83

Restore old semantics of "netdata -W set" command (#8987)

Markos Fountoulakis committed May 12, 2020 at 20:08 UTC 26a113a8357e1db70e1f92a1b42fff581b8e9108
2 files changed +31 -1
claim/README.md
+1 -1
@@ -121,7 +121,7 @@ docker run -d --name=netdata \
121 --cap-add SYS_PTRACE \
122 --security-opt apparmor=unconfined \
123 netdata/netdata \
124 - /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"
124 + /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"
125 ```
126
127 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
daemon/main.c
+30
@@ -1086,6 +1086,36 @@ int main(int argc, char **argv) {
1086 debug_flags = strtoull(optarg, NULL, 0);
1087 }
1088 else if(strcmp(optarg, "set") == 0) {
1089 + if(optind + 3 > argc) {
1090 + fprintf(stderr, "%s", "\nUSAGE: -W set 'section' 'key' 'value'\n\n"
1091 + " Overwrites settings of netdata.conf.\n"
1092 + "\n"
1093 + " These options interact with: -c netdata.conf\n"
1094 + " If -c netdata.conf is given on the command line,\n"
1095 + " before -W set... the user may overwrite command\n"
1096 + " line parameters at netdata.conf\n"
1097 + " If -c netdata.conf is given after (or missing)\n"
1098 + " -W set... the user cannot overwrite the command line\n"
1099 + " parameters."
1100 + "\n"
1101 + );
1102 + return 1;
1103 + }
1104 + const char *section = argv[optind];
1105 + const char *key = argv[optind + 1];
1106 + const char *value = argv[optind + 2];
1107 + optind += 3;
1108 +
1109 + // set this one as the default
1110 + // only if it is not already set in the config file
1111 + // so the caller can use -c netdata.conf before or
1112 + // after this parameter to prevent or allow overwriting
1113 + // variables at netdata.conf
1114 + config_set_default(section, key, value);
1115 +
1116 + // fprintf(stderr, "SET section '%s', key '%s', value '%s'\n", section, key, value);
1117 + }
1118 + else if(strcmp(optarg, "set2") == 0) {
1119 if(optind + 4 > argc) {
1120 fprintf(stderr, "%s", "\nUSAGE: -W set 'conf_file' 'section' 'key' 'value'\n\n"
1121 " Overwrites settings of netdata.conf or cloud.conf\n"