[hobbit] Possible bugs

Henrik Stoerner henrik at hswn.dk
Sun Apr 10 14:59:11 CEST 2005


On Thu, Apr 07, 2005 at 04:42:00PM -0500, Stuffle, David wrote:
> Just a few things that may be bugs:
> 1. If I define an alert with DURATION>90, the info column shows it as "1h"
> instead of "90min".

Indeed, there were some missing parenthesis and stuff in the routine
that did this string formatting. Fixed with the first of the attached
patches.


> 2. Hobbit-alerts.cfg says that you can do HOST=%www.* to match anything
> *starting* with www, but I'm seeing that it actually matches *anything* with
> www in it.  I had to do HOST=%^www.*.  I guess if I knew Perl regex better I
> would have realized this in the first place.

Me too :-) I've corrected to sample regex to match the description.


> 3. On the bb2 page, in the list of events in the past xxx minutes, if a test
> goes from "red/yellow/green" to blue, and you click on the blue image, it
> doesn't show the blue status page.  It shows the status of what it changed
> from.  All other colors seem to work fine, just blue does this.

After digging around for some time, I found out that this is really an
issue that happens with the Hobbit-internal status changes (blue and
purple) - you'll also see it if you go via the "History" button and
select a blue or purple log.

When a status goes blue or purple, this only changes the color stored
internally in Hobbit, it doesn't change the actual status message text
that is stored in the historical logfile (which includes the
color-text). So all of the Hobbit-maintained event-logs will show the
correct color, but the historical logfile does not. So I fixed this in
the module that saves the historical log - this means that it will not
have any effect on the previous historical logs, only on the ones that
are processed after you install the patch.


Regards,
Henrik
-------------- next part --------------
--- lib/timefunc.c	2005/03/27 06:56:44	1.18
+++ lib/timefunc.c	2005/04/10 12:04:24
@@ -345,32 +345,42 @@
 
 char *durationstring(time_t secs)
 {
+#define ONE_WEEK   (7*24*60*60)
+#define ONE_DAY    (24*60*60)
+#define ONE_HOUR   (60*60)
+#define ONE_MINUTE (60)
+
 	static char result[50];
 	char *p = result;
 	time_t v = secs;
+	int n;
 
 	if (secs == 0) return "-";
 
 	*result = '\0';
 
-	if (v >= 7*24*60*60) {
-		p += sprintf(p, "%dw ", (int)(v / (7*24*60*60)));
-		v = (v % 7*24*60*60);
+	if (v >= ONE_WEEK) {
+		n = (int) (v / ONE_WEEK);
+		p += sprintf(p, "%dw ", n);
+		v -= (n * ONE_WEEK);
 	}
 
-	if (v >= 24*60*60) {
-		p += sprintf(p, "%dd ", (int)(v / (24*60*60)));
-		v = (v % 24*60*60);
+	if (v >= ONE_DAY) {
+		n = (int) (v / ONE_DAY);
+		p += sprintf(p, "%dd ", n);
+		v -= (n * ONE_DAY);
 	}
 
-	if (v >= 60*60) {
-		p += sprintf(p, "%dh ", (int)(v / (60*60)));
-		v = (v % 60*60);
+	if (v >= ONE_HOUR) {
+		n = (int) (v / ONE_HOUR);
+		p += sprintf(p, "%dh ", n);
+		v -= (n * ONE_HOUR);
 	}
 
-	if (v >= 60) {
-		p += sprintf(p, "%dm ", (int)(v / 60));
-		v = (v % 60);
+	if (v >= ONE_MINUTE) {
+		n = (int) (v / ONE_MINUTE);
+		p += sprintf(p, "%dm ", n);
+		v -= (n * ONE_MINUTE);
 	}
 
 	if (v > 0) {
-------------- next part --------------
--- hobbitd/hobbitd_history.c	2005/03/25 21:13:41	1.33
+++ hobbitd/hobbitd_history.c	2005/04/10 12:47:40
@@ -174,6 +174,20 @@
 
 				histlogfd = fopen(fname, "w");
 				if (histlogfd) {
+					/*
+					 * When a host gets disabled or goes purple, the status
+					 * message data is not changed - so it will include a
+					 * wrong color as the first word of the message.
+					 * Therefore we need to fixup this so it matches the
+					 * newcolor value.
+					 */
+					int txtcolor = parse_color(statusdata);
+
+					if (txtcolor != -1) {
+						fprintf(histlogfd, "%s", colorname(newcolor));
+						statusdata += strlen(colorname(txtcolor));
+					}
+
 					fwrite(statusdata, strlen(statusdata), 1, histlogfd);
 					fprintf(histlogfd, "Status unchanged in 0.00 minutes\n");
 					fprintf(histlogfd, "Message received from %s\n", items[2]);


More information about the Xymon mailing list