Bug in downtime display on info-page
list Johan Sjöberg
Hi. This might already be fixed in 4.3, but I'll report it anyway. The info page in 4.2.3 shows the downtime information in the wrong order. In bb-host I added "DOWNTIME=*:5:0445:0555:reboot" to schedule a downtime each Friday morning for a reboot of a server. I know this downtime works as intended, and the field order is according to the man-page. But on the info-page, the downtime is shown as "Planned downtime:All days:5:0445:0555:reboot", so the "day" and "service" fields are mixed up. /Johan
list Henrik Størner
▸
In <user-bf0c013603b4@xymon.invalid> =?iso-8859-1?Q?Johan_Sj=F6berg?= <user-74c177c1220d@xymon.invalid> writes:
This might already be fixed in 4.3, but I'll report it anyway. The info page in 4.2.3 shows the downtime information in the wrong order. In bb-host I added "DOWNTIME=*:5:0445:0555:reboot" to schedule a downtime each Friday morning for a reboot of a server. I know this downtime works as intended, and the field order is according to the man-page. But on the info-page, the downtime is shown as "Planned downtime:All days:5:0445:0555:reboot", so the "day" and "service" fields are mixed up.
Thanks for reporting this - the routine handling the time-display had
not been updated to support the extended format. Fixed now. The patch
below can be applied to 4.2.3 also, if you want to.
Regards,
Henrik
Index: lib/timefunc.c
===================================================================
--- lib/timefunc.c (revision 6532)
+++ lib/timefunc.c (working copy)
@@ -97,6 +97,7 @@
static strbuffer_t *result = NULL;
char *sCopy;
char *sItem;
+ char *itmstbuf;
if (result == NULL) result = newstrbuffer(0);
clearstrbuffer(result);
@@ -120,12 +121,36 @@
}
sCopy = strdup(spec);
- sItem = strtok(sCopy, ",");
+ sItem = strtok_r(sCopy, ",", &itmstbuf);
while (sItem) {
+ char *tok, *onebuf, *e1, *e2, *e3, *e4, *e5;
+ char *days, *starttime, *endtime, *columns, *cause;
char *oneday, *dtext;
- int daysdone = 0, firstday = 1;
- oneday = sItem;
+ int daysdone = 0, firstday = 1, ecount;
+ e1 = e2 = e3 = e4 = e5 = NULL; ecount = 0;
+ e1 = strtok_r(sItem, ":", &onebuf);
+ if (e1) { ecount++; e2 = strtok_r(NULL, ":", &onebuf); }
+ if (e2) { ecount++; e3 = strtok_r(NULL, ":", &onebuf); }
+ if (e3) { ecount++; e4 = strtok_r(NULL, ":", &onebuf); }
+ if (e4) { ecount++; e5 = strtok_r(NULL, ":", &onebuf); }
+ if (e5) { ecount++; }
• + if (ecount == 3) {
+ /* Old format: e1=day, e2 = starttime, e3 = endtime */
+ days = e1; starttime = e2; endtime = e3; columns = NULL; cause = NULL;
+ }
+ else if (ecount == 5) {
+ columns = e1; days = e2; starttime = e3; endtime = e4; cause = e5;
+ }
+ else {
+ addtobuffer(result, "[Malformed timespec]");
+ sItem = NULL;
+ continue;
+ }
• + oneday = days;
• while (!daysdone) {
switch (*oneday) {
case '*': dtext = "All days"; break;
@@ -141,12 +166,25 @@
}
if (!firstday) addtobuffer(result, "/");
• addtobuffer(result, dtext);
oneday++;
firstday = 0;
}
- sItem = strtok(NULL, ",");
+ addtobuffer(result, ":"); addtobuffer(result, starttime);
+ addtobuffer(result, ":"); addtobuffer(result, endtime);
+ if (columns) {
+ addtobuffer(result, " (status:");
+ if (strcmp(columns, "*") == 0)
+ addtobuffer(result, "All");
+ else
+ addtobuffer(result, columns);
+ addtobuffer(result, ")");
+ }
+ if (cause) { addtobuffer(result, " (cause:"); addtobuffer(result, cause); addtobuffer(result, ")"); }
• + sItem = strtok_r(NULL, ",", &itmstbuf);
if (sItem) addtobuffer(result, ", ");
}
xfree(sCopy);
list Dominique Frise
Hi, After applying the patch below on a 4.3.0-beta2 installation, the optional "columns" setting is not displayed correctly. Example rule from bb-hosts DOWNTIME=orcl,orcl-chk,http:*:0655:1115:Backups Info display Planned downtime: [Malformed timespec] Dominique
▸
On 10/29/10 12:47 PM, Henrik Størner wrote:In<user-bf0c013603b4@xymon.invalid> =?iso-8859-1?Q?Johan_Sj=F6berg?=<user-74c177c1220d@xymon.invalid> writes:This might already be fixed in 4.3, but I'll report it anyway. The info page in 4.2.3 shows the downtime information in the wrong order. In bb-host I added "DOWNTIME=*:5:0445:0555:reboot" to schedule a downtime each Friday morning for a reboot of a server. I know this downtime works as intended, and the field order is according to the man-page. But on the info-page, the downtime is shown as "Planned downtime:All days:5:0445:0555:reboot", so the "day" and "service" fields are mixed up.Thanks for reporting this - the routine handling the time-display had not been updated to support the extended format. Fixed now. The patch below can be applied to 4.2.3 also, if you want to. Regards, Henrik Index: lib/timefunc.c =================================================================== --- lib/timefunc.c (revision 6532) +++ lib/timefunc.c (working copy) @@ -97,6 +97,7 @@ static strbuffer_t *result = NULL; char *sCopy; char *sItem; + char *itmstbuf; if (result == NULL) result = newstrbuffer(0); clearstrbuffer(result); @@ -120,12 +121,36 @@ } sCopy = strdup(spec); - sItem = strtok(sCopy, ","); + sItem = strtok_r(sCopy, ",",&itmstbuf); while (sItem) { + char *tok, *onebuf, *e1, *e2, *e3, *e4, *e5; + char *days, *starttime, *endtime, *columns, *cause; char *oneday, *dtext; - int daysdone = 0, firstday = 1; - oneday = sItem; + int daysdone = 0, firstday = 1, ecount; + e1 = e2 = e3 = e4 = e5 = NULL; ecount = 0; + e1 = strtok_r(sItem, ":",&onebuf); + if (e1) { ecount++; e2 = strtok_r(NULL, ":",&onebuf); } + if (e2) { ecount++; e3 = strtok_r(NULL, ":",&onebuf); } + if (e3) { ecount++; e4 = strtok_r(NULL, ":",&onebuf); } + if (e4) { ecount++; e5 = strtok_r(NULL, ":",&onebuf); } + if (e5) { ecount++; } • + if (ecount == 3) { + /* Old format: e1=day, e2 = starttime, e3 = endtime */ + days = e1; starttime = e2; endtime = e3; columns = NULL; cause = NULL; + } + else if (ecount == 5) { + columns = e1; days = e2; starttime = e3; endtime = e4; cause = e5; + } + else { + addtobuffer(result, "[Malformed timespec]"); + sItem = NULL; + continue; + } • + oneday = days; • while (!daysdone) { switch (*oneday) { case '*': dtext = "All days"; break; @@ -141,12 +166,25 @@ } if (!firstday) addtobuffer(result, "/"); • addtobuffer(result, dtext); oneday++; firstday = 0; } - sItem = strtok(NULL, ","); + addtobuffer(result, ":"); addtobuffer(result, starttime); + addtobuffer(result, ":"); addtobuffer(result, endtime); + if (columns) { + addtobuffer(result, " (status:"); + if (strcmp(columns, "*") == 0) + addtobuffer(result, "All"); + else + addtobuffer(result, columns); + addtobuffer(result, ")"); + } + if (cause) { addtobuffer(result, " (cause:"); addtobuffer(result, cause); addtobuffer(result, ")"); } • + sItem = strtok_r(NULL, ",",&itmstbuf); if (sItem) addtobuffer(result, ", "); } xfree(sCopy);
list Sebastian Auriol
▸
Dominique Frise <mailto:user-78ab6673b600@xymon.invalid> wrote:
Hi, After applying the patch below on a 4.3.0-beta2 installation, the optional "columns" setting is not displayed correctly. Example rule from bb-hosts DOWNTIME=orcl,orcl-chk,http:*:0655:1115:Backups Info display Planned downtime: [Malformed timespec] Dominique On 10/29/10 12:47 PM, Henrik Størner wrote:
<snip>
Not sure if Henrik or anyone mentionned this to you, or if you subscribe to Xymon-developer and saw it yourself, but an hour after your e-mail Henrik committed this change to the 4.3.0 branch in subversion: Revision: 6556 http://xymon.svn.sourceforge.net/xymon/?rev=6556&view=rev Author: storner Date: 2010-11-02 14:47:11 +0000 (Tue, 02 Nov 2010) Log Message: Downtime printing: Fix broken downtime-display when multiple columns listed Modified Paths: branches/4.3.0/lib/timefunc.c I presume that this fixes your issue. Kind regards, SebA
list Dominique Frise
▸
On 11/ 5/10 02:35 PM, SebA wrote:
Dominique Frise<mailto:user-78ab6673b600@xymon.invalid> wrote:Hi, After applying the patch below on a 4.3.0-beta2 installation, the optional "columns" setting is not displayed correctly. Example rule from bb-hosts DOWNTIME=orcl,orcl-chk,http:*:0655:1115:Backups Info display Planned downtime: [Malformed timespec] Dominique On 10/29/10 12:47 PM, Henrik Størner wrote:<snip> Not sure if Henrik or anyone mentionned this to you, or if you subscribe to Xymon-developer and saw it yourself, but an hour after your e-mail Henrik committed this change to the 4.3.0 branch in subversion: Revision: 6556 http://xymon.svn.sourceforge.net/xymon/?rev=6556&view=rev Author: storner Date: 2010-11-02 14:47:11 +0000 (Tue, 02 Nov 2010) Log Message: Downtime printing: Fix broken downtime-display when multiple columns listed Modified Paths: branches/4.3.0/lib/timefunc.c I presume that this fixes your issue. Kind regards, SebA
Yes it does :-) Henrik sent me a patch off list that I successfully tested before he commited the new changes in branches/4.3.0/lib/timefunc. Thanks Dominique