Title: [opsview-base] [227] Fix linefeeds coming from slaves, broken due to subsequent processing within Nagios
Revision
227
Author
tvoon
Date
2013-03-22 16:25:48 +0000 (Fri, 22 Mar 2013)

Log Message

Fix linefeeds coming from slaves, broken due to subsequent processing within Nagios

Modified Paths

Added Paths

Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2013-03-08 06:22:19 UTC (rev 226)
+++ trunk/Makefile	2013-03-22 16:25:48 UTC (rev 227)
@@ -604,6 +604,9 @@
 	cd ${NAGIOS} && patch -p1 < ../patches/nagios_overcome_log_rotation_overwrites.patch
 	cd ${NAGIOS} && patch -p1 < ../patches/nagios_reentrant_localtime.patch
 	cd ${NAGIOS} && patch -p1 < ../patches/nagios_fix_multiple_log_rotations.patch
+	# Patch below to test that results from slaves get linefeeds converted correctly
+	# Test with: perl -e 'print "opsview\tHTTP\t3\thelp\\nwith single \\ and\\n double \\\\ for all",$/' | send_nrd -c /usr/local/nagios/etc/send_nrd.cfg
+	cd ${NAGIOS} && patch -p1 < ../patches/nagios_convert_to_linefeeds_from_checkresults.patch
 	if [ $(KERNEL_NAME) = Linux ] ; then \
 		cd ${NAGIOS} && CFLAGS="${CFLAGS}" ./configure --with-nagios-user=$(NAGIOS_USER) --with-nagios-group=$(NAGIOS_GROUP) --with-command-group=$(NAGIOS_GROUP) --with-cgiurl=/cgi-bin --with-htmurl=/ --enable-libtap ; \
 	elif [ $(KERNEL_NAME) = Darwin ] ; then \

Added: trunk/patches/nagios_convert_to_linefeeds_from_checkresults.patch
===================================================================
--- trunk/patches/nagios_convert_to_linefeeds_from_checkresults.patch	                        (rev 0)
+++ trunk/patches/nagios_convert_to_linefeeds_from_checkresults.patch	2013-03-22 16:25:48 UTC (rev 227)
@@ -0,0 +1,33 @@
+Binary files nagios-4.0.20130107.original/base/nagios and nagios-4.0.20130107/base/nagios differ
+diff -ur nagios-4.0.20130107.original/base/utils.c nagios-4.0.20130107/base/utils.c
+--- nagios-4.0.20130107.original/base/utils.c	2013-03-22 15:54:58.000000000 +0000
++++ nagios-4.0.20130107/base/utils.c	2013-03-22 16:21:26.000000000 +0000
+@@ -2256,8 +2256,26 @@
+ 				cr.exited_ok = atoi(val);
+ 			else if(!strcmp(var, "return_code"))
+ 				cr.return_code = atoi(val);
+-			else if(!strcmp(var, "output"))
++			else if(!strcmp(var, "output")) {
+ 				cr.output = (char *)strdup(val);
++
++				// Opsview patch: The checkresults dir is only for NRD type data now
++				// We convert \n to actual linefeeds, because the subsequent parse_check_result
++				// expects linefeeds in the stream
++				// This wasn't required in Nagios 3 but processing has changed somewhere in 4
++				int x,y;
++				char *buf = cr.output;
++				for(x=0,y=0;buf[x]!='\x0';x++){
++					if(buf[x]=='\\' && buf[x+1]=='n'){
++						x++;
++						buf[y++]='\n';
++						}
++					else
++						buf[y++]=buf[x];
++					}
++				buf[y]='\x0';
++				}
++
+ 			}
+ 		}
+ 
+Binary files nagios-4.0.20130107.original/base/utils.o and nagios-4.0.20130107/base/utils.o differ

_______________________________________________
Opsview-checkins mailing list
Opsview-checkins@lists.opsview.org
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to