Skip to content

Commit 045e8fa

Browse files
committed
clients/ups{cmd,rw}.c: make the "OK" without "TRACKING" warning visible; introduce NUT_QUIET_OK_NOTRACKING to hide it though [#3383]
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent 9a397d6 commit 045e8fa

4 files changed

Lines changed: 29 additions & 7 deletions

File tree

NEWS.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,11 @@ several `FSD` notifications into one executed action. [PR #3097]
401401

402402
- `upsc` has now optional JSON output [issue #3172, PR #3178]
403403

404+
- `upscmd` and `upsrw` clients would now report that the "OK" response only
405+
means that the server accepted the query, if wait mode ("TRACKING") was
406+
not specified, and what users could do about it (e.g. use the `-w` option
407+
or `export NUT_QUIET_OK_NOTRACKING=true` to hide the warning). [issue #3383]
408+
404409
- `upsset` CGI tool should now recognize `RANGE NUMBER` and `NUMBER` types.
405410
[#3164]
406411

clients/upscmd.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,19 @@ static void do_cmd(char **argv, const int argc)
211211
/* sanity check on the size: "OK TRACKING " + UUID4_LEN */
212212
strlen(buf) != (UUID4_LEN - 1 + strlen("OK TRACKING "))
213213
) {
214+
char *e = getenv("NUT_QUIET_OK_NOTRACKING");
215+
int lvl = 0; /* Visible by default */
216+
217+
if (e && !strcmp(e, "true"))
218+
lvl = 1; /* Hide into debuging if asked to */
219+
214220
/* reply as usual */
215221
fprintf(stderr, "%s\n", buf);
216-
upsdebugx(1, "%s: 'OK' only means the NUT data server accepted the request as valid, "
217-
"but as we did not wait for result, we do not know if it was handled in fact.",
218-
__func__);
222+
upsdebugx(lvl, "%s: 'OK' only means the NUT data server accepted the request as valid, "
223+
"but as we did not wait for result, we do not know if it was handled in fact.%s",
224+
lvl ? __func__ : "WARNING",
225+
lvl ? "" : " You can export NUT_QUIET_OK_NOTRACKING=true to hide this message, or use -w (-t SEC) option(s) to track the actual outcome."
226+
);
219227
return;
220228
}
221229

clients/upsrw.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,19 @@ static void do_set(const char *varname, const char *newval)
141141
/* sanity check on the size: "OK TRACKING " + UUID4_LEN */
142142
strlen(buf) != (UUID4_LEN - 1 + strlen("OK TRACKING "))
143143
) {
144+
char *e = getenv("NUT_QUIET_OK_NOTRACKING");
145+
int lvl = 0; /* Visible by default */
146+
147+
if (e && !strcmp(e, "true"))
148+
lvl = 1; /* Hide into debuging if asked to */
149+
144150
/* reply as usual */
145151
fprintf(stderr, "%s\n", buf);
146-
upsdebugx(1, "%s: 'OK' only means the NUT data server accepted the request as valid, "
147-
"but as we did not wait for result, we do not know if it was handled in fact.",
148-
__func__);
152+
upsdebugx(lvl, "%s: 'OK' only means the NUT data server accepted the request as valid, "
153+
"but as we did not wait for result, we do not know if it was handled in fact.%s",
154+
lvl ? __func__ : "WARNING",
155+
lvl ? "" : " You can export NUT_QUIET_OK_NOTRACKING=true to hide this message, or use -w (-t SEC) option(s) to track the actual outcome."
156+
);
149157
return;
150158
}
151159

docs/nut.dict

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
personal_ws-1.1 en 3727 utf-8
1+
personal_ws-1.1 en 3728 utf-8
22
AAC
33
AAS
44
ABI
@@ -835,6 +835,7 @@ NOTIFYMSG
835835
NOTOFF
836836
NOTOTHER
837837
NOTOVER
838+
NOTRACKING
838839
NOTTRIM
839840
NQA
840841
NTFS

0 commit comments

Comments
 (0)