[hobbit] Coredump when generating pre-built reports

Henrik Stoerner henrik at hswn.dk
Fri Dec 2 17:06:18 CET 2005


On Fri, Dec 02, 2005 at 09:31:31AM -0000, Morris, Chris (Shared Services) wrote:
> On Thursday, December 01, 2005 4:35 PM, Frédéric Mangeant wrote:
> 
> >I tried to generate the november monthly report, and bbgen coredumped :
> >
> >$ ~/server/bin/bbcmd --env=/BB/hobbit/server/etc/hobbitserver.cfg 
> >hobbitreports.sh monthly
> >~/server/bin/hobbitreports.sh: line 78: 24827 Abandon                 
> >(core dumped) BBWEB=$REPORTTOPURL/$REPDIR $BBHOME/bin/bbgen 
> >--reportopts=$STIME:$ETIME:0:nongr $BBGENREPOPTS $REPORTTOPDIR/$REPDIR
> 
> I have a similar problem on an AIX server (5.1 or 5.2) using 4.1.2p1 in that
> bbgen coredumps generating any automated reports
> but works ok doing a "custom" report

I suspect this is somewhat the same problem both of you are seeing.
Could you try the attached patch and let me know if it helps ?

Henrik

-------------- next part --------------
--- bbdisplay/reportdata.c	2005/05/02 10:30:12	1.36
+++ bbdisplay/reportdata.c	2005/12/02 16:04:01
@@ -11,7 +11,7 @@
 /*                                                                            */
 /*----------------------------------------------------------------------------*/
 
-static char rcsid[] = "$Id: reportdata.c,v 1.36 2005/05/02 10:30:12 henrik Exp $";
+static char rcsid[] = "$Id: reportdata.c,v 1.37 2005/12/02 16:03:45 henrik Exp $";
 
 #include <limits.h>
 #include <stdio.h>
@@ -304,23 +304,27 @@
 static char *timename(char *timestring)
 {
 	static char timespec[26];
-
-	char timecopy[26];
-	char *token;
+	char *timecopy;
+	char *tokens[5];
 	int i;
 
 	/* Compute the timespec string used as the name of the historical logfile */
-	strncpy(timecopy, timestring, 25);
-	timecopy[25] = '\0';
-
-	token = strtok(timecopy, " ");
-	strcpy(timespec, token);
-
-	for (i=1; i<5; i++) {
-		strcat(timespec, "_");
-		token = strtok(NULL, " ");
-		strcat(timespec, token);
+	*timespec = '\0';
+	timecopy = strdup(timestring);
+	tokens[0] = tokens[1] = tokens[2] = tokens[3] = tokens[4] = NULL;
+
+	tokens[0] = strtok(timecopy, " "); i = 0;
+	while (tokens[i] && (i < 4)) { i++; tokens[i] = strtok(NULL, " "); }
+
+	if (tokens[4]) {
+		/* Got all 5 elements */
+		snprintf(timespec, sizeof(timespec), "%s_%s_%s_%s_%s",
+			 tokens[0], tokens[1], tokens[2], tokens[3], tokens[4]);
 	}
+	else {
+		errprintf("Bad timespec in history file: %s\n", timestring);
+	}
+	xfree(timecopy);
 
 	return timespec;
 }
@@ -410,12 +414,12 @@
 				newentry->color = color;
 				newentry->affectssla = (reporttime && (sladuration > 0));
 
-				if (!for_history && (color != COL_GREEN)) {
+				if (!for_history && timespec && (color != COL_GREEN)) {
 					newentry->cause = parse_histlogfile(hostname, servicename, timespec);
 				}
 				else newentry->cause = "";
 
-				newentry->timespec = strdup(timespec);
+				newentry->timespec = (timespec ? strdup(timespec): NULL);
 				newentry->next = reploghead;
 				reploghead = newentry;
 			}
@@ -502,7 +506,9 @@
 	time_t duration;
 	char colstr[MAX_LINE_LEN];
 	int color;
+	char *p;
 
+	*histlogname = NULL;
 	fileerrors = scan_historyfile(fd, snapshot, snapshot, 
 				      l, sizeof(l), starttime, &duration, colstr);
 	
@@ -512,7 +518,8 @@
 		color = -2;
 	}
 
-	*histlogname = strdup(timename(l));
+	p = timename(l);
+	if (p) *histlogname = strdup(p);
 
 	return color;
 }


More information about the Xymon mailing list