Help with DOWNTIME tag
list Terry Barnes
Just took the plunge to HOBBIT today and overall it is working very nice. Big Brother has been great - this is going to be a winner! Reading through the bb-hosts manpage i discovered the DOWNTIME tag. This is great by its description. I have been preventing alerts at specified times of the day, but unfortunately things still go red, though no alerts go out. If I understand DOWNTIME correctly, it should allow failed tests during this downtime window to result in a blue status instead of red. I added it to bb-hosts on a host specific line similar to the following. 1.2.3.4 myhost.com # DOWNTIME=*:2259:0531test1 test2 test3 test4 test... I anxiously awaited the moment several processes stopped for dayend backups and processing, but the staus went red as usual. Am i coding this wrong or not understnding its implementation correctly? Thanks Terry Barnes Siemens Com @ HFHS XXX-XXX-XXXX (Office) XXX-XXX-XXXX (Cellular) XXX-XXX-XXXX (Fax) user-34ea5ff61ded@xymon.invalid (Text Pager) user-0e29285d9a67@xymon.invalid CONFIDENTIALITY NOTICE: This email contains information from the sender that may be CONFIDENTIAL, LEGALLY PRIVILEGED, PROPRIETARY or otherwise protected from disclosure. This email is intended for use only by the person or entity to whom it is addressed. If you are not the intended recipient, any use, disclosure, copying, distribution, printing, or any action taken in reliance on the contents of this email, is strictly prohibited. If you received this email in error, please contact the sending party by replying in an email to the sender, delete the email from your computer system and shred any paper copies of the email you printed. Note to Patients: There are a number of risks you should consider before using e-mail to communicate with us. These risks are described in our Privacy Policy at http://henryford.com. Review that policy carefully before continuing to communicate with us by e-mail. For greater Internet security, our policy describes the Henry Ford MyHealth electronic communication process - you may register at http://henryford.com. If you do not believe that our policy gives you the privacy and security protection you need, do not send e-mail or Internet communications to us.
Attachments (1)
list Henrik Størner
▸
On Thu, Mar 24, 2005 at 11:43:59PM -0500, Terry Barnes wrote:
Just took the plunge to HOBBIT today and overall it is working very nice. Big Brother has been great - this is going to be a winner! Reading through the bb-hosts manpage i discovered the DOWNTIME tag.
[snip description of it not working]
I think you're right - there is a bug in how this is handled. Glad you
spotted it.
Attached is a patch for this. To apply it, save the attachment to
/tmp/postrc6-downtime.patch, and:
cd hobbit-4.0-RC6
patch -p0 </tmp/postrc6-downtime.patch
make
Stop Hobbit, su to root and run "make install", then start Hobbit
again.
Regards,
Henrik
-------------- next part --------------
--- bbdisplay/loadbbhosts.c 2005/01/20 10:45:44 1.18
+++ bbdisplay/loadbbhosts.c 2005/03/25 07:41:56
@@ -1,22 +1,16 @@
/*----------------------------------------------------------------------------*/
-/* Big Brother webpage generator tool. */
+/* Hobbit overview webpage generator tool. */
/* */
-/* This is a replacement for the "mkbb.sh" and "mkbb2.sh" scripts from the */
-/* "Big Brother" monitoring tool from BB4 Technologies. */
+/* This file contains code to load the page-structure from the bb-hosts file. */
/* */
-/* Primary reason for doing this: Shell scripts perform badly, and with a */
-/* medium-sized installation (~150 hosts) it takes several minutes to */
-/* generate the webpages. This is a problem, when the pages are used for */
-/* 24x7 monitoring of the system status. */
-/* */
-/* Copyright (C) 2002 Henrik Storner <user-e180c691dbbd@xymon.invalid> */
+/* Copyright (C) 2002-2005 Henrik Storner <user-e180c691dbbd@xymon.invalid> */
/* */
/* This program is released under the GNU General Public License (GPL), */
/* version 2. See the file "COPYING" for details. */
/* */
/*----------------------------------------------------------------------------*/
-static char rcsid[] = "$Id: loadbbhosts.c,v 1.18 2005/01/20 10:45:44 henrik Exp $";
+static char rcsid[] = "$Id: loadbbhosts.c,v 1.20 2005/03/25 07:40:15 henrik Exp $";
#include <limits.h>
#include <stdio.h>
@@ -616,7 +610,7 @@
dialup = (bbh_item(bbhost, BBH_FLAG_DIALUP) != NULL);
nobb2 = (bbh_item(bbhost, BBH_FLAG_NOBB2) != NULL);
alertlist = bbh_item(bbhost, BBH_NK);
- bbval = bbh_item(bbhost, BBH_NKTIME); if (bbval) nktime = within_sla(bbval, "", 0);
+ bbval = bbh_item(bbhost, BBH_NKTIME); if (bbval) nktime = within_sla(bbval, 0);
onwaplist = bbh_item(bbhost, BBH_WML);
nopropyellowlist = bbh_item(bbhost, BBH_NOPROPYELLOW);
if (nopropyellowlist == NULL) nopropyellowlist = bbh_item(bbhost, BBH_NOPROP);
--- bbnet/bbtest-net.c 2005/03/05 06:54:29 1.203
+++ bbnet/bbtest-net.c 2005/03/25 07:41:54
@@ -8,7 +8,7 @@
/* */
/*----------------------------------------------------------------------------*/
-static char rcsid[] = "$Id: bbtest-net.c,v 1.203 2005/03/05 06:54:29 henrik Exp $";
+static char rcsid[] = "$Id: bbtest-net.c,v 1.207 2005/03/25 07:40:15 henrik Exp $";
#include <limits.h>
#include <stdio.h>
@@ -459,7 +459,7 @@
p = bbh_item(hwalk, BBH_DOWNTIME);
- if (p) okexpected = (!within_sla(p, "", 0));
+ if (p) okexpected = (!within_sla(p, 0));
h = init_testedhost(hwalk->bbhostname, okexpected);
p = bbh_custom_item(hwalk, "badconn:");
--- common/bbhostgrep.c 2005/01/31 22:30:23 1.24
+++ common/bbhostgrep.c 2005/03/25 07:41:54
@@ -13,7 +13,7 @@
/* */
/*----------------------------------------------------------------------------*/
-static char rcsid[] = "$Id: bbhostgrep.c,v 1.24 2005/01/31 22:30:23 henrik Exp $";
+static char rcsid[] = "$Id: bbhostgrep.c,v 1.25 2005/03/25 07:40:15 henrik Exp $";
#include <stdio.h>
#include <string.h>
@@ -130,7 +130,7 @@
if (bbh_item(hwalk, BBH_FLAG_DIALUP)) strcat(wantedtags, " dialup");
if (bbh_item(hwalk, BBH_FLAG_TESTIP)) strcat(wantedtags, " testip");
if ((item = bbh_item(hwalk, BBH_DOWNTIME)) != NULL) {
- if (within_sla(item, "", 0))
+ if (within_sla(item, 0))
strcat(wantedtags, " OUTSIDESLA");
else
strcat(wantedtags, " INSIDESLA");
--- hobbitd/do_alert.c 2005/03/20 13:52:05 1.57
+++ hobbitd/do_alert.c 2005/03/25 07:41:53
@@ -13,7 +13,7 @@
/* */
/*----------------------------------------------------------------------------*/
-static char rcsid[] = "$Id: do_alert.c,v 1.57 2005/03/20 13:52:05 henrik Exp $";
+static char rcsid[] = "$Id: do_alert.c,v 1.58 2005/03/25 07:40:15 henrik Exp $";
/*
* The alert API defines three functions that must be implemented:
@@ -860,7 +860,7 @@
{
int result;
- result = within_sla(tspec, "", 0);
+ result = within_sla(tspec, 0);
return result;
}
--- lib/loadhosts.c 2005/01/31 11:39:16 1.24
+++ lib/loadhosts.c 2005/03/25 07:41:52
@@ -1,11 +1,11 @@
/*----------------------------------------------------------------------------*/
-/* Hobbit monitor. */
+/* Hobbit monitor library. */
/* */
/* This is a library module for Hobbit, responsible for loading the bb-hosts */
/* file and keeping track of what hosts are known, their aliases and planned */
/* downtime settings etc. */
/* */
-/* Copyright (C) 2004 Henrik Storner <user-ce4a2c883f75@xymon.invalid> */
+/* Copyright (C) 2004-2005 Henrik Storner <user-ce4a2c883f75@xymon.invalid> */
/* */
/* This program is released under the GNU General Public License (GPL), */
/* version 2. See the file "COPYING" for details. */
@@ -13,7 +13,7 @@
/*----------------------------------------------------------------------------*/
-static char rcsid[] = "$Id: loadhosts.c,v 1.24 2005/01/31 11:39:16 henrik Exp $";
+static char rcsid[] = "$Id: loadhosts.c,v 1.26 2005/03/25 07:40:15 henrik Exp $";
#include <stdio.h>
#include <string.h>
@@ -151,7 +151,7 @@
*/
strcpy(hostip, walk->ip);
strcpy(result, walk->bbhostname);
- if (walk->downtime) *maybedown = within_sla(walk->downtime, "DOWNTIME", 0);
+ if (walk->downtime) *maybedown = within_sla(walk->downtime, 0);
}
else {
strcpy(result, hostname);
--- lib/timefunc.c 2005/02/20 09:03:48 1.14
+++ lib/timefunc.c 2005/03/25 08:33:28
@@ -1,17 +1,17 @@
/*----------------------------------------------------------------------------*/
-/* bbgen toolkit */
+/* Hobbit monitor library. */
/* */
/* This is a library module, part of libbbgen. */
/* It contains routines for timehandling. */
/* */
-/* Copyright (C) 2002-2004 Henrik Storner <user-e180c691dbbd@xymon.invalid> */
+/* Copyright (C) 2002-2005 Henrik Storner <user-e180c691dbbd@xymon.invalid> */
/* */
/* This program is released under the GNU General Public License (GPL), */
/* version 2. See the file "COPYING" for details. */
/* */
/*----------------------------------------------------------------------------*/
-static char rcsid[] = "$Id: timefunc.c,v 1.14 2005/02/20 09:03:48 henrik Exp $";
+static char rcsid[] = "$Id: timefunc.c,v 1.17 2005/03/25 08:33:05 henrik Exp $";
#include <time.h>
#include <sys/time.h>
@@ -109,91 +109,90 @@
static int minutes(char *p)
{
/* Converts string HHMM to number indicating minutes since midnight (0-1440) */
- return (10*(*(p+0)-'0')+(*(p+1)-'0'))*60 + (10*(*(p+2)-'0')+(*(p+3)-'0'));
+ if (isdigit((int)*(p+0)) && isdigit((int)*(p+1)) && isdigit((int)*(p+2)) && isdigit((int)*(p+3))) {
+ return (10*(*(p+0)-'0')+(*(p+1)-'0'))*60 + (10*(*(p+2)-'0')+(*(p+3)-'0'));
+ }
+ else {
+ errprintf("Invalid timespec - expected 4 digits, got: '%s'\n", p);
+ return 0;
+ }
}
-int within_sla(char *l, char *tag, int defresult)
+int within_sla(char *timespec, int defresult)
{
/*
- * Usage: slatime hostline
- * SLASPEC is of the form SLA=W:HHMM:HHMM[,WXHHMM:HHMM]*
+ * timespec is of the form W:HHMM:HHMM[,W:HHMM:HHMM]*
* "W" = weekday : '*' = all, 'W' = Monday-Friday, '0'..'6' = Sunday ..Saturday
*/
- char *p;
- char *slaspec = NULL;
- char *endofslaspec = NULL;
- char *tagspec;
• + int found = 0;
time_t tnow;
struct tm *now;
+ int curtime;
+ char *onesla;
- int result = 0;
- int found = 0;
- int starttime,endtime,curtime;
+ if (!timespec) return defresult;
- if (strlen(tag)) {
- tagspec = (char *) malloc(strlen(tag)+2);
- sprintf(tagspec, "%s=", tag);
- p = strstr(l, tagspec);
- }
- else {
- tagspec = strdup("");
- p = l;
- }
+ tnow = time(NULL);
+ now = localtime(&tnow);
+ curtime = now->tm_hour*60+now->tm_min;
- if (p) {
- slaspec = p + strlen(tagspec);
- endofslaspec = slaspec + strcspn(slaspec, " \t\r\n");
- tnow = time(NULL);
- now = localtime(&tnow);
• - /*
- * Now find the appropriate SLA definition.
- * We take advantage of the fixed (11 bytes + delimiter) length of each entry.
- */
- while ( (!found) && slaspec && (slaspec < endofslaspec) )
- {
- dprintf("Now checking slaspec='%s'\n", slaspec);
• - if ( (*slaspec == '*') || /* Any day */
- (*slaspec == now->tm_wday+'0') || /* This day */
- ((toupper((int)*slaspec) == 'W') && (now->tm_wday >= 1) && (now->tm_wday <=5)) ) /* Monday thru Friday */
- {
- /* Weekday matches */
- starttime = minutes(slaspec+2);
- endtime = minutes(slaspec+7);
- curtime = now->tm_hour*60+now->tm_min;
- if (endtime > starttime) {
- /* *:0200:0400 */
- found = ((curtime >= starttime) && (curtime <= endtime));
- }
- else {
- /* The period crosses over midnight: *:2330:0400 */
- found = ((curtime >= starttime) || (curtime <= endtime));
- }
+ onesla = timespec;
+ while (!found && onesla) {
- dprintf("\tstart,end,current time = %d, %d, %d - found=%d\n",
- starttime,endtime,curtime,found);
- }
- else {
- dprintf("\tWeekday does not match\n");
+ int wdaymatch = 0;
+ char *endsla, *starttimep, *endtimep;
+ int starttime, endtime;
• + endsla = strchr(onesla, ','); if (endsla) *endsla = '\0';
• + if (*onesla == '*') {
+ wdaymatch = 1;
+ }
+ else if ((toupper((int)*onesla) == 'W') && (now->tm_wday >= 1) && (now->tm_wday <=5)) {
+ wdaymatch = 1;
+ }
+ else {
+ char *wday;
+ for (wday = onesla; ((*wday >= '0') && (*wday <= '6')); wday++) {
+ if (*wday == (now->tm_wday+'0')) wdaymatch = 1;
}
+ if (*wday != ':') errprintf("Bad timespec (missing colon or wrong weekdays): %s\n", onesla);
+ }
- if (!found) {
- slaspec = strchr(slaspec, ',');
- if (slaspec) slaspec++;
- };
+ if (wdaymatch) {
+ /* Weekday matches */
+ starttimep = strchr(onesla, ':');
+ if (starttimep) {
+ starttime = minutes(starttimep+1);
+ endtimep = strchr(starttimep+1, ':');
+ if (endtimep) {
+ endtime = minutes(endtimep+1);
+ if (endtime > starttime) {
+ /* *:0200:0400 */
+ found = ((curtime >= starttime) && (curtime <= endtime));
+ }
+ else {
+ /* The period crosses over midnight: *:2330:0400 */
+ found = ((curtime >= starttime) || (curtime <= endtime));
+ }
+ dprintf("\tstart,end,current time = %d, %d, %d - found=%d\n",
+ starttime,endtime,curtime,found);
+ }
+ else errprintf("Bad timespec (missing colon or no endtime): %s\n", onesla);
+ }
+ else errprintf("Bad timespec (missing colon or no starttime): %s\n", onesla);
}
- result = found;
- }
- else {
- /* No SLA -> use the default */
- result = defresult;
+ else {
+ dprintf("\tWeekday does not match\n");
+ }
• + /* Go to next SLA spec. */
+ if (endsla) *endsla = ',';
+ onesla = (endsla ? (endsla + 1) : NULL);
}
- xfree(tagspec);
- return result;
+ return found;
}
--- lib/timefunc.h 2005/02/20 08:19:11 1.5
+++ lib/timefunc.h 2005/03/25 07:20:59
@@ -1,7 +1,7 @@
/*----------------------------------------------------------------------------*/
-/* bbgen toolkit */
+/* Hobbit monitor library. */
/* */
-/* Copyright (C) 2002-2004 Henrik Storner <user-e180c691dbbd@xymon.invalid> */
+/* Copyright (C) 2002-2005 Henrik Storner <user-e180c691dbbd@xymon.invalid> */
/* */
/* This program is released under the GNU General Public License (GPL), */
/* version 2. See the file "COPYING" for details. */
@@ -17,7 +17,7 @@
extern char *weekday_text(char *dayspec);
extern char *time_text(char *timespec);
extern struct timeval *tvdiff(struct timeval *tstart, struct timeval *tend, struct timeval *result);
-extern int within_sla(char *l, char *tag, int defresult);
+extern int within_sla(char *l, int defresult);
extern int periodcoversnow(char *tag);
extern char *histlogtime(time_t histtime);
extern int durationvalue(char *dur);
list Terry Barnes
Yikes - I did this and now I have everything green alright - problem is there are no hosts listed. Everything is gone except the "Pages hosted locally" page links. Tried enable/disable - no hosts listed on that either.
▸
Terry Barnes
Siemens Com @ HFHS
XXX-XXX-XXXX (Office)
XXX-XXX-XXXX (Cellular)
XXX-XXX-XXXX (Fax)
user-34ea5ff61ded@xymon.invalid (Text Pager)
user-0e29285d9a67@xymon.invalid
user-ce4a2c883f75@xymon.invalid 3/25/05 3:36:39 AM >>>
▸
On Thu, Mar 24, 2005 at 11:43:59PM -0500, Terry Barnes wrote:
Just took the plunge to HOBBIT today and overall it is working very nice. Big Brother has been great - this is going to be a winner! Reading through the bb-hosts manpage i discovered the DOWNTIME tag.
[snip description of it not working] I think you're right - there is a bug in how this is handled. Glad you spotted it. Attached is a patch for this. To apply it, save the attachment to /tmp/postrc6-downtime.patch, and: cd hobbit-4.0-RC6 patch -p0 </tmp/postrc6-downtime.patch make Stop Hobbit, su to root and run "make install", then start Hobbit again. Regards, Henrik CONFIDENTIALITY NOTICE: This email contains information from the sender that may be CONFIDENTIAL, LEGALLY PRIVILEGED, PROPRIETARY or otherwise protected from disclosure. This email is intended for use only by the person or entity to whom it is addressed. If you are not the intended recipient, any use, disclosure, copying, distribution, printing, or any action taken in reliance on the contents of this email, is strictly prohibited. If you received this email in error, please contact the sending party by replying in an email to the sender, delete the email from your computer system and shred any paper copies of the email you printed. Note to Patients: There are a number of risks you should consider before using e-mail to communicate with us. These risks are described in our Privacy Policy at http://henryford.com. Review that policy carefully before continuing to communicate with us by e-mail. For greater Internet security, our policy describes the Henry Ford MyHealth electronic communication process - you may register at http://henryford.com. If you do not believe that our policy gives you the privacy and security protection you need, do not send e-mail or Internet communications to us.
list Terry Barnes
▸
user-ce4a2c883f75@xymon.invalid 3/25/05 3:36:39 AM >>>
On Thu, Mar 24, 2005 at 11:43:59PM -0500, Terry Barnes wrote:
Just took the plunge to HOBBIT today and overall it is working very nice. Big Brother has been great - this is going to be a winner! Reading through the bb-hosts manpage i discovered the DOWNTIME tag. [snip description of it not working] I think you're right - there is a bug in how this is handled. Glad you spotted it. Attached is a patch for this. To apply it, save the attachment to /tmp/postrc6-downtime.patch, and: cd hobbit-4.0-RC6 patch -p0 </tmp/postrc6-downtime.patch make Stop Hobbit, su to root and run "make install", then start Hobbit again. Regards, Henrik
Yikes - I did this and now I have everything green alright - problem is there are no hosts listed. Everything is gone except the "Pages hosted locally" page links. Tried enable/disable - no hosts listed on that either.
bb-display.log, bb-network.log and bb-retest.log shows
2005-03-25 13:03:52 Could not connect to bbd at x.x.x.x:1984 - Connection
refused
2005-03-25 13:03:52 Whoops ! bb failed to send message - Connection
failed
2005-03-25 13:03:52 hobbitd status-board not available (this line only
in bb-display.log)
netstat -an|grep 1984 - returns nothing
Any ideas?
▸
Terry Barnes Siemens Com @ HFHS XXX-XXX-XXXX (Office) XXX-XXX-XXXX (Cellular) XXX-XXX-XXXX (Fax) user-34ea5ff61ded@xymon.invalid (Text Pager) user-0e29285d9a67@xymon.invalid CONFIDENTIALITY NOTICE: This email contains information from the sender that may be CONFIDENTIAL, LEGALLY PRIVILEGED, PROPRIETARY or otherwise protected from disclosure. This email is intended for use only by the person or entity to whom it is addressed. If you are not the intended recipient, any use, disclosure, copying, distribution, printing, or any action taken in reliance on the contents of this email, is strictly prohibited. If you received this email in error, please contact the sending party by replying in an email to the sender, delete the email from your computer system and shred any paper copies of the email you printed. Note to Patients: There are a number of risks you should consider before using e-mail to communicate with us. These risks are described in our Privacy Policy at http://henryford.com. Review that policy carefully before continuing to communicate with us by e-mail. For greater Internet security, our policy describes the Henry Ford MyHealth electronic communication process - you may register at http://henryford.com. If you do not believe that our policy gives you the privacy and security protection you need, do not send e-mail or Internet communications to us.
list Henrik Størner
On Fri, Mar 25, 2005 at 12:50:24PM -0500, Terry Barnes wrote:
Yikes - I did this and now I have everything green alright
So no worries, then :-)
▸
- problem is there are no hosts listed. Everything is gone except the "Pages hosted locally" page links. Tried enable/disable - no hosts listed on that either.
Sounds like I broke something badly. Could you check the hobbitlaunch.log and see if there are any messages about "hobbit" terminating ? Sounds like it crashed. Henrik
list Henrik Størner
▸
On Fri, Mar 25, 2005 at 10:50:39PM +0100, Henrik Stoerner wrote:
On Fri, Mar 25, 2005 at 12:50:24PM -0500, Terry Barnes wrote:Yikes - I did this and now I have everything green alrightSo no worries, then :-)- problem is there are no hosts listed. Everything is gone except the "Pages hosted locally" page links. Tried enable/disable - no hosts listed on that either.
I think this was an effect of the disk handler problem in the first post-RC6 patch. If you grab the current one from http://www.hswn.dk/beta/post-RC6-v2.patch, it should work OK. Regards, Henrik