[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [hobbit] NCV handler problem



Matti Klock wrote:
> Is there a better way to get the NCV handler to ignore the colon in
> http://? I'm running the snapshot from 21 Sep 2005 right now.

Never mind, I figured it out. I'm having the same problem as Mario Andre
did on 23 Sep.

The NCV handler appears to have two bugs. First, it captures data of the
form <name>:<string>, as well as of the form <name>:<number>; second, it
reads beyond the end of the message sometimes, producing some really
bewildering errors in rrd-status.log.

This small patch fixed both problems, for what it's worth.

Thanks,
Matti
--- hobbitd/rrd/do_ncv.c	2005-09-30 18:01:32.000000000 -0400
+++ hobbitd/rrd/do_ncv.c	2005-09-30 17:19:58.000000000 -0400
@@ -43,10 +43,20 @@
 		name = val = NULL;
 
 		l += strspn(l, " \t\n");
-		if (*l) { name = l; l += strcspn(l, ":="); *l = '\0'; l++; }
-		if (name) { val = l + strspn(l, " \t"); l = val + strspn(val, "0123456789."); *l = '\0'; l++; }
+		if (*l) { 
+			name = l; 
+			l += strcspn(l, ":="); 
+			if( *l ) { *l = '\0'; l++; }
+			else break;
+		}
+		if (name) { 
+			val = l + strspn(l, " \t"); 
+			l = val + strspn(val, "0123456789."); 
+			if( *l ) { *l = '\0'; l++; }
+			else break;
+		}
 
-		if (name && val) {
+		if (name && val && *val) {
 			char *endptr;
 
 			strtod(val, &endptr);