1 |
dertobi123 09/12/31 10:06:19 |
2 |
|
3 |
Added: multiline.patch |
4 |
Log: |
5 |
Revbump, add support for large, multiline output (#264467). Also do respect LDFALGS when building nrpe_check_control. |
6 |
(Portage version: 2.2_rc61/cvs/Linux x86_64) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 net-analyzer/nagios-nrpe/files/multiline.patch |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-analyzer/nagios-nrpe/files/multiline.patch?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-analyzer/nagios-nrpe/files/multiline.patch?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: multiline.patch |
15 |
=================================================================== |
16 |
diff -ur nrpe-2.12.original/include/common.h nrpe-2.12/include/common.h |
17 |
--- nrpe-2.12.original/include/common.h 2008-03-10 22:04:42.000000000 +0100 |
18 |
+++ nrpe-2.12/include/common.h 2008-08-05 00:27:10.664753368 +0200 |
19 |
@@ -41,7 +41,7 @@ |
20 |
#define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */ |
21 |
#define DEFAULT_CONNECTION_TIMEOUT 300 /* timeout if daemon is waiting for connection more than this time */ |
22 |
|
23 |
-#define MAX_INPUT_BUFFER 2048 /* max size of most buffers we use */ |
24 |
+#define MAX_INPUT_BUFFER 16384 /* max size of most buffers we use */ |
25 |
#define MAX_FILENAME_LENGTH 256 |
26 |
|
27 |
#define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */ |
28 |
@@ -55,12 +55,14 @@ |
29 |
|
30 |
#define QUERY_PACKET 1 /* id code for a packet containing a query */ |
31 |
#define RESPONSE_PACKET 2 /* id code for a packet containing a response */ |
32 |
+#define RESPONSE_PACKET_WITH_MORE 3 /* id code for a packet containing a response, with more data to follow */ |
33 |
|
34 |
#define NRPE_PACKET_VERSION_3 3 /* packet version identifier */ |
35 |
#define NRPE_PACKET_VERSION_2 2 |
36 |
#define NRPE_PACKET_VERSION_1 1 /* older packet version identifiers (no longer supported) */ |
37 |
|
38 |
-#define MAX_PACKETBUFFER_LENGTH 1024 /* max amount of data we'll send in one query/response */ |
39 |
+#define MAX_PACKETBUFFER_LENGTH 1024 /* max amount of data we'll send in one query/response. WARNING - do not change this |
40 |
+ as older clients/servers will not work */ |
41 |
|
42 |
typedef struct packet_struct{ |
43 |
int16_t packet_version; |
44 |
Binary files nrpe-2.12.original/src/check_nrpe and nrpe-2.12/src/check_nrpe differ |
45 |
diff -ur nrpe-2.12.original/src/check_nrpe.c nrpe-2.12/src/check_nrpe.c |
46 |
--- nrpe-2.12.original/src/check_nrpe.c 2008-03-10 22:04:43.000000000 +0100 |
47 |
+++ nrpe-2.12/src/check_nrpe.c 2008-08-05 00:48:00.731981872 +0200 |
48 |
@@ -221,6 +221,11 @@ |
49 |
return STATE_UNKNOWN; |
50 |
} |
51 |
|
52 |
+ /* Altinity patch: Allow multiple packets to be received */ |
53 |
+ /* Indentation not corrected to allow simpler patching */ |
54 |
+ /* START MULTI_PACKET LOOP */ |
55 |
+ do { |
56 |
+ |
57 |
/* wait for the response packet */ |
58 |
bytes_to_recv=sizeof(receive_packet); |
59 |
if(use_ssl==FALSE) |
60 |
@@ -233,31 +238,24 @@ |
61 |
/* reset timeout */ |
62 |
alarm(0); |
63 |
|
64 |
- /* close the connection */ |
65 |
-#ifdef HAVE_SSL |
66 |
- if(use_ssl==TRUE){ |
67 |
- SSL_shutdown(ssl); |
68 |
- SSL_free(ssl); |
69 |
- SSL_CTX_free(ctx); |
70 |
- } |
71 |
-#endif |
72 |
- graceful_close(sd,1000); |
73 |
- |
74 |
/* recv() error */ |
75 |
if(rc<0){ |
76 |
printf("CHECK_NRPE: Error receiving data from daemon.\n"); |
77 |
+ graceful_close(sd,1000); |
78 |
return STATE_UNKNOWN; |
79 |
} |
80 |
|
81 |
/* server disconnected */ |
82 |
else if(rc==0){ |
83 |
printf("CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.\n"); |
84 |
+ graceful_close(sd,1000); |
85 |
return STATE_UNKNOWN; |
86 |
} |
87 |
|
88 |
/* receive underflow */ |
89 |
else if(bytes_to_recv<sizeof(receive_packet)){ |
90 |
printf("CHECK_NRPE: Receive underflow - only %d bytes received (%d expected).\n",bytes_to_recv,sizeof(receive_packet)); |
91 |
+ graceful_close(sd,1000); |
92 |
return STATE_UNKNOWN; |
93 |
} |
94 |
|
95 |
@@ -271,21 +269,21 @@ |
96 |
calculated_crc32=calculate_crc32((char *)&receive_packet,sizeof(receive_packet)); |
97 |
if(packet_crc32!=calculated_crc32){ |
98 |
printf("CHECK_NRPE: Response packet had invalid CRC32.\n"); |
99 |
- close(sd); |
100 |
+ graceful_close(sd,1000); |
101 |
return STATE_UNKNOWN; |
102 |
} |
103 |
|
104 |
/* check packet version */ |
105 |
if(ntohs(receive_packet.packet_version)!=NRPE_PACKET_VERSION_2){ |
106 |
printf("CHECK_NRPE: Invalid packet version received from server.\n"); |
107 |
- close(sd); |
108 |
+ graceful_close(sd,1000); |
109 |
return STATE_UNKNOWN; |
110 |
} |
111 |
|
112 |
/* check packet type */ |
113 |
- if(ntohs(receive_packet.packet_type)!=RESPONSE_PACKET){ |
114 |
+ if(ntohs(receive_packet.packet_type)!=RESPONSE_PACKET && ntohs(receive_packet.packet_type)!=RESPONSE_PACKET_WITH_MORE){ |
115 |
printf("CHECK_NRPE: Invalid packet type received from server.\n"); |
116 |
- close(sd); |
117 |
+ graceful_close(sd,1000); |
118 |
return STATE_UNKNOWN; |
119 |
} |
120 |
|
121 |
@@ -297,8 +295,18 @@ |
122 |
if(!strcmp(receive_packet.buffer,"")) |
123 |
printf("CHECK_NRPE: No output returned from daemon.\n"); |
124 |
else |
125 |
- printf("%s\n",receive_packet.buffer); |
126 |
- } |
127 |
+ printf("%s",receive_packet.buffer); |
128 |
+ |
129 |
+ } while (ntohs(receive_packet.packet_type)==RESPONSE_PACKET_WITH_MORE); |
130 |
+ /* END MULTI_PACKET LOOP */ |
131 |
+ |
132 |
+ /* Finish output with newline */ |
133 |
+ printf("\n"); |
134 |
+ |
135 |
+ /* close the connection */ |
136 |
+ graceful_close(sd,1000); |
137 |
+ |
138 |
+ } |
139 |
|
140 |
/* reset the alarm */ |
141 |
else |
142 |
@@ -434,6 +442,14 @@ |
143 |
struct timeval tv; |
144 |
char buf[1000]; |
145 |
|
146 |
+#ifdef HAVE_SSL |
147 |
+ if(use_ssl==TRUE){ |
148 |
+ SSL_shutdown(ssl); |
149 |
+ SSL_free(ssl); |
150 |
+ SSL_CTX_free(ctx); |
151 |
+ } |
152 |
+#endif |
153 |
+ |
154 |
/* send FIN packet */ |
155 |
shutdown(sd,SHUT_WR); |
156 |
for(;;){ |
157 |
Binary files nrpe-2.12.original/src/nrpe and nrpe-2.12/src/nrpe differ |
158 |
diff -ur nrpe-2.12.original/src/nrpe.c nrpe-2.12/src/nrpe.c |
159 |
--- nrpe-2.12.original/src/nrpe.c 2008-08-04 16:17:25.729637000 +0200 |
160 |
+++ nrpe-2.12/src/nrpe.c 2008-08-05 00:52:47.690415400 +0200 |
161 |
@@ -1029,6 +1029,8 @@ |
162 |
char processed_command[MAX_INPUT_BUFFER]; |
163 |
int result=STATE_OK; |
164 |
int early_timeout=FALSE; |
165 |
+ int bytes_copied=0; |
166 |
+ char *pbuffer=&buffer[0]; |
167 |
int rc; |
168 |
int x; |
169 |
#ifdef DEBUG |
170 |
@@ -1245,6 +1247,14 @@ |
171 |
if(buffer[strlen(buffer)-1]=='\n') |
172 |
buffer[strlen(buffer)-1]='\x0'; |
173 |
|
174 |
+ /* Altinity patch to allow multi packet responses */ |
175 |
+ /* Loop not indented to allow easier patching */ |
176 |
+ /* START MULTI_PACKET LOOP */ |
177 |
+ do { |
178 |
+ |
179 |
+ if(debug==TRUE) |
180 |
+ syslog(LOG_DEBUG,"Sending response - bytes left: %d", strlen(pbuffer)); |
181 |
+ |
182 |
/* clear the response packet buffer */ |
183 |
bzero(&send_packet,sizeof(send_packet)); |
184 |
|
185 |
@@ -1253,11 +1263,17 @@ |
186 |
|
187 |
/* initialize response packet data */ |
188 |
send_packet.packet_version=(int16_t)htons(NRPE_PACKET_VERSION_2); |
189 |
- send_packet.packet_type=(int16_t)htons(RESPONSE_PACKET); |
190 |
send_packet.result_code=(int16_t)htons(result); |
191 |
- strncpy(&send_packet.buffer[0],buffer,MAX_PACKETBUFFER_LENGTH); |
192 |
+ strncpy(&send_packet.buffer[0],pbuffer,MAX_PACKETBUFFER_LENGTH); |
193 |
send_packet.buffer[MAX_PACKETBUFFER_LENGTH-1]='\x0'; |
194 |
|
195 |
+ bytes_copied = strlen(&send_packet.buffer[0]); |
196 |
+ pbuffer = pbuffer+bytes_copied; |
197 |
+ if(strlen(pbuffer)>0) |
198 |
+ send_packet.packet_type=(int16_t)htons(RESPONSE_PACKET_WITH_MORE); |
199 |
+ else |
200 |
+ send_packet.packet_type=(int16_t)htons(RESPONSE_PACKET); |
201 |
+ |
202 |
/* calculate the crc 32 value of the packet */ |
203 |
send_packet.crc32_value=(u_int32_t)0L; |
204 |
calculated_crc32=calculate_crc32((char *)&send_packet,sizeof(send_packet)); |
205 |
@@ -1276,6 +1292,9 @@ |
206 |
SSL_write(ssl,&send_packet,bytes_to_send); |
207 |
#endif |
208 |
|
209 |
+ } while (strlen(pbuffer) > 0); |
210 |
+ /* END MULTI_PACKET LOOP */ |
211 |
+ |
212 |
#ifdef HAVE_SSL |
213 |
if(ssl){ |
214 |
SSL_shutdown(ssl); |