1 |
flameeyes 12/08/23 23:07:05 |
2 |
|
3 |
Added: nrpe.init nrpe-nagios3-r1 nrpe.xinetd |
4 |
nagios-nrpe-2.13-tcpd.patch |
5 |
nagios-nrpe-2.13-command-args.patch nrpe.xinetd.2 |
6 |
nagios-nrpe-2.13-multiline.patch nrpe-nagios3 |
7 |
Log: |
8 |
Move from net-analyzer/nagios-nrpe to net-analyzer/nrpe, as the package work with Icinga just fine. |
9 |
|
10 |
(Portage version: 2.2.0_alpha121/cvs/Linux x86_64, RepoMan options: --force) |
11 |
|
12 |
Revision Changes Path |
13 |
1.1 net-analyzer/nrpe/files/nrpe.init |
14 |
|
15 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nrpe.init?rev=1.1&view=markup |
16 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nrpe.init?rev=1.1&content-type=text/plain |
17 |
|
18 |
Index: nrpe.init |
19 |
=================================================================== |
20 |
#!/sbin/runscript |
21 |
# Copyright 1999-2012 Gentoo Foundation |
22 |
# Distributed under the terms of the GNU General Public License v2 |
23 |
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/nrpe/files/nrpe.init,v 1.1 2012/08/23 23:07:05 flameeyes Exp $ |
24 |
|
25 |
: ${CFGFILE:=/etc/nagios/nrpe.cfg} |
26 |
|
27 |
get_config() { |
28 |
[ -f ${CFGFILE} ] || return 1 |
29 |
|
30 |
sed -n -e 's:^[ \t]*'$1'=\([^#]\+\).*:\1:p' \ |
31 |
${CFGFILE} |
32 |
} |
33 |
|
34 |
extra_started_commands="reload" |
35 |
|
36 |
command=/usr/libexec/${SVCNAME} |
37 |
command_args="-c ${CFGFILE} --daemon" |
38 |
pidfile=$(get_config pid_file) |
39 |
|
40 |
depend() { |
41 |
config ${CFGFILE} |
42 |
need net |
43 |
} |
44 |
|
45 |
reload() { |
46 |
ebegin "Reloading ${SVCNAME}" |
47 |
kill -HUP `cat $(get_config pid_file)` |
48 |
eend $? |
49 |
} |
50 |
|
51 |
|
52 |
|
53 |
1.1 net-analyzer/nrpe/files/nrpe-nagios3-r1 |
54 |
|
55 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nrpe-nagios3-r1?rev=1.1&view=markup |
56 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nrpe-nagios3-r1?rev=1.1&content-type=text/plain |
57 |
|
58 |
Index: nrpe-nagios3-r1 |
59 |
=================================================================== |
60 |
#!/sbin/runscript |
61 |
|
62 |
extra_started_commands="reload" |
63 |
|
64 |
command="/usr/bin/nrpe" |
65 |
command_args="-c /etc/nagios/nrpe.cfg --daemon" |
66 |
pidfile="${pidfile:-/var/run/nrpe/nrpe.pid}" |
67 |
start_stop_daemon_args="--user nagios --group nagios" |
68 |
|
69 |
depend() { |
70 |
need net |
71 |
} |
72 |
|
73 |
start_pre() { |
74 |
checkpath -d -m 0750 -o nagios:nagios /var/run/nrpe |
75 |
} |
76 |
|
77 |
reload() { |
78 |
ebegin "Reloading nrpe" |
79 |
kill -HUP $(head -n1 ${pidfile}) |
80 |
eend $? "Failed to reload nrpe" |
81 |
} |
82 |
|
83 |
|
84 |
|
85 |
1.1 net-analyzer/nrpe/files/nrpe.xinetd |
86 |
|
87 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nrpe.xinetd?rev=1.1&view=markup |
88 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nrpe.xinetd?rev=1.1&content-type=text/plain |
89 |
|
90 |
Index: nrpe.xinetd |
91 |
=================================================================== |
92 |
service nrpe { |
93 |
socket_type = stream |
94 |
protocol = tcp |
95 |
wait = no |
96 |
user = nagios |
97 |
group = nagios |
98 |
server = /usr/bin/nrpe |
99 |
server_args = -c /etc/nagios/nrpe.cfg --inetd |
100 |
# only_from = 127.0.0.1 |
101 |
disabled = yes |
102 |
} |
103 |
|
104 |
|
105 |
|
106 |
1.1 net-analyzer/nrpe/files/nagios-nrpe-2.13-tcpd.patch |
107 |
|
108 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nagios-nrpe-2.13-tcpd.patch?rev=1.1&view=markup |
109 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nagios-nrpe-2.13-tcpd.patch?rev=1.1&content-type=text/plain |
110 |
|
111 |
Index: nagios-nrpe-2.13-tcpd.patch |
112 |
=================================================================== |
113 |
--- configure.in.orig 2008-03-10 22:04:41.000000000 +0100 |
114 |
+++ configure.in 2012-01-08 17:59:49.804613011 +0100 |
115 |
@@ -147,11 +147,27 @@ |
116 |
AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl") |
117 |
AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket") |
118 |
AC_SUBST(SOCKETLIBS) |
119 |
-AC_CHECK_LIB(wrap,main,[ |
120 |
- LIBWRAPLIBS="$LIBWRAPLIBS -lwrap" |
121 |
+ |
122 |
+AC_ARG_ENABLE(tcp-wrapper,--enable-tcp-wrapper enables support for TCP wrappers. *** DISABLING IS A SECURITY RISK! *** Read the SECURITY file before using this option! (default: auto),[ |
123 |
+ if test x$enableval = xyes; then |
124 |
+ enable_tcp_wrapper=yes |
125 |
+ else |
126 |
+ enable_tcp_wrapper=no |
127 |
+ fi |
128 |
+ ],enable_tcp_wrapper="auto") |
129 |
+ |
130 |
+LIBWRAPLIBS="" |
131 |
+if test "x$enable_tcp_wrapper" = "xauto"; then |
132 |
+ AC_CHECK_LIB(wrap,main,[ |
133 |
+ LIBWRAPLIBS="$LIBWRAPLIBS -lwrap" |
134 |
+ AC_DEFINE(HAVE_LIBWRAP) |
135 |
+ ]) |
136 |
+elif test "x$enable_tcp_wrapper" = "xyes"; then |
137 |
+ AC_CHECK_LIB(wrap,main,LIBWRAPLIBS="$LIBWRAPLIBS -lwrap",[AC_MSG_ERROR([TCP wrapper library not found])]) |
138 |
AC_DEFINE(HAVE_LIBWRAP) |
139 |
- ]) |
140 |
+fi |
141 |
AC_SUBST(LIBWRAPLIBS) |
142 |
+ |
143 |
AC_CHECK_FUNCS(strdup strstr strtoul initgroups closesocket) |
144 |
|
145 |
dnl socklen_t check - from curl |
146 |
|
147 |
|
148 |
|
149 |
1.1 net-analyzer/nrpe/files/nagios-nrpe-2.13-command-args.patch |
150 |
|
151 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nagios-nrpe-2.13-command-args.patch?rev=1.1&view=markup |
152 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nagios-nrpe-2.13-command-args.patch?rev=1.1&content-type=text/plain |
153 |
|
154 |
Index: nagios-nrpe-2.13-command-args.patch |
155 |
=================================================================== |
156 |
--- configure.old 2008-03-10 22:04:41.000000000 +0100 |
157 |
+++ configure.in 2012-01-04 09:46:38.000000000 +0100 |
158 |
@@ -362,7 +362,11 @@ |
159 |
AC_SUBST(NAGIOS_INSTALL_OPTS) |
160 |
|
161 |
|
162 |
-AC_ARG_ENABLE(command-args,--enable-command-args allows clients to specify command arguments. *** THIS IS A SECURITY RISK! *** Read the SECURITY file before using this option!,AC_DEFINE_UNQUOTED(ENABLE_COMMAND_ARGUMENTS)) |
163 |
+AC_ARG_ENABLE(command-args,--enable-command-args allows clients to specify command arguments. *** THIS IS A SECURITY RISK! *** Read the SECURITY file before using this option!,[ |
164 |
+ if test x$enableval = xyes; then |
165 |
+ AC_DEFINE_UNQUOTED(ENABLE_COMMAND_ARGUMENTS) |
166 |
+ fi |
167 |
+ ]) |
168 |
|
169 |
|
170 |
AC_PATH_PROG(PERL,perl) |
171 |
|
172 |
|
173 |
|
174 |
1.1 net-analyzer/nrpe/files/nrpe.xinetd.2 |
175 |
|
176 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nrpe.xinetd.2?rev=1.1&view=markup |
177 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nrpe.xinetd.2?rev=1.1&content-type=text/plain |
178 |
|
179 |
Index: nrpe.xinetd.2 |
180 |
=================================================================== |
181 |
/nrpe |
182 |
server_args = -c /etc/nagios/nrpe.cfg --inetd |
183 |
# only_from = 127.0.0.1 |
184 |
disabled = yes |
185 |
} |
186 |
|
187 |
|
188 |
|
189 |
1.1 net-analyzer/nrpe/files/nagios-nrpe-2.13-multiline.patch |
190 |
|
191 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nagios-nrpe-2.13-multiline.patch?rev=1.1&view=markup |
192 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nagios-nrpe-2.13-multiline.patch?rev=1.1&content-type=text/plain |
193 |
|
194 |
Index: nagios-nrpe-2.13-multiline.patch |
195 |
=================================================================== |
196 |
diff --git a/include/common.h b/include/common.h |
197 |
index 202dec4..86f8e32 100755 |
198 |
--- a/include/common.h |
199 |
+++ b/include/common.h |
200 |
@@ -41,7 +41,7 @@ |
201 |
#define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */ |
202 |
#define DEFAULT_CONNECTION_TIMEOUT 300 /* timeout if daemon is waiting for connection more than this time */ |
203 |
|
204 |
-#define MAX_INPUT_BUFFER 2048 /* max size of most buffers we use */ |
205 |
+#define MAX_INPUT_BUFFER 16384 /* max size of most buffers we use */ |
206 |
#define MAX_FILENAME_LENGTH 256 |
207 |
|
208 |
#define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */ |
209 |
@@ -55,12 +55,14 @@ |
210 |
|
211 |
#define QUERY_PACKET 1 /* id code for a packet containing a query */ |
212 |
#define RESPONSE_PACKET 2 /* id code for a packet containing a response */ |
213 |
+#define RESPONSE_PACKET_WITH_MORE 3 /* id code for a packet containing a response, with more data to follow */ |
214 |
|
215 |
#define NRPE_PACKET_VERSION_3 3 /* packet version identifier */ |
216 |
#define NRPE_PACKET_VERSION_2 2 |
217 |
#define NRPE_PACKET_VERSION_1 1 /* older packet version identifiers (no longer supported) */ |
218 |
|
219 |
#define MAX_PACKETBUFFER_LENGTH 1024 /* max amount of data we'll send in one query/response */ |
220 |
+ /* WARNING - do not change this as older clients/servers will not work */ |
221 |
|
222 |
typedef struct packet_struct{ |
223 |
int16_t packet_version; |
224 |
diff --git a/src/check_nrpe.c b/src/check_nrpe.c |
225 |
index 0adced1..ff4b920 100755 |
226 |
--- a/src/check_nrpe.c |
227 |
+++ b/src/check_nrpe.c |
228 |
@@ -221,6 +221,11 @@ int main(int argc, char **argv){ |
229 |
return STATE_UNKNOWN; |
230 |
} |
231 |
|
232 |
+ /* Altinity patch: Allow multiple packets to be received */ |
233 |
+ /* Indentation not corrected to allow simpler patching */ |
234 |
+ /* START MULTI_PACKET LOOP */ |
235 |
+ do { |
236 |
+ |
237 |
/* wait for the response packet */ |
238 |
bytes_to_recv=sizeof(receive_packet); |
239 |
if(use_ssl==FALSE) |
240 |
@@ -233,31 +238,24 @@ int main(int argc, char **argv){ |
241 |
/* reset timeout */ |
242 |
alarm(0); |
243 |
|
244 |
- /* close the connection */ |
245 |
-#ifdef HAVE_SSL |
246 |
- if(use_ssl==TRUE){ |
247 |
- SSL_shutdown(ssl); |
248 |
- SSL_free(ssl); |
249 |
- SSL_CTX_free(ctx); |
250 |
- } |
251 |
-#endif |
252 |
- graceful_close(sd,1000); |
253 |
- |
254 |
/* recv() error */ |
255 |
if(rc<0){ |
256 |
printf("CHECK_NRPE: Error receiving data from daemon.\n"); |
257 |
+ graceful_close(sd,1000); |
258 |
return STATE_UNKNOWN; |
259 |
} |
260 |
|
261 |
/* server disconnected */ |
262 |
else if(rc==0){ |
263 |
printf("CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.\n"); |
264 |
+ graceful_close(sd,1000); |
265 |
return STATE_UNKNOWN; |
266 |
} |
267 |
|
268 |
/* receive underflow */ |
269 |
else if(bytes_to_recv<sizeof(receive_packet)){ |
270 |
printf("CHECK_NRPE: Receive underflow - only %d bytes received (%d expected).\n",bytes_to_recv,sizeof(receive_packet)); |
271 |
+ graceful_close(sd,1000); |
272 |
return STATE_UNKNOWN; |
273 |
} |
274 |
|
275 |
@@ -271,21 +269,21 @@ int main(int argc, char **argv){ |
276 |
calculated_crc32=calculate_crc32((char *)&receive_packet,sizeof(receive_packet)); |
277 |
if(packet_crc32!=calculated_crc32){ |
278 |
printf("CHECK_NRPE: Response packet had invalid CRC32.\n"); |
279 |
- close(sd); |
280 |
+ graceful_close(sd,1000); |
281 |
return STATE_UNKNOWN; |
282 |
} |
283 |
|
284 |
/* check packet version */ |
285 |
if(ntohs(receive_packet.packet_version)!=NRPE_PACKET_VERSION_2){ |
286 |
printf("CHECK_NRPE: Invalid packet version received from server.\n"); |
287 |
- close(sd); |
288 |
+ graceful_close(sd,1000); |
289 |
return STATE_UNKNOWN; |
290 |
} |
291 |
|
292 |
/* check packet type */ |
293 |
- if(ntohs(receive_packet.packet_type)!=RESPONSE_PACKET){ |
294 |
+ if(ntohs(receive_packet.packet_type)!=RESPONSE_PACKET && ntohs(receive_packet.packet_type)!=RESPONSE_PACKET_WITH_MORE){ |
295 |
printf("CHECK_NRPE: Invalid packet type received from server.\n"); |
296 |
- close(sd); |
297 |
+ graceful_close(sd,1000); |
298 |
return STATE_UNKNOWN; |
299 |
} |
300 |
|
301 |
@@ -297,8 +295,18 @@ int main(int argc, char **argv){ |
302 |
if(!strcmp(receive_packet.buffer,"")) |
303 |
printf("CHECK_NRPE: No output returned from daemon.\n"); |
304 |
else |
305 |
- printf("%s\n",receive_packet.buffer); |
306 |
- } |
307 |
+ printf("%s",receive_packet.buffer); |
308 |
+ |
309 |
+ } while (ntohs(receive_packet.packet_type)==RESPONSE_PACKET_WITH_MORE); |
310 |
+ /* END MULTI_PACKET LOOP */ |
311 |
+ |
312 |
+ /* Finish output with newline */ |
313 |
+ printf("\n"); |
314 |
+ |
315 |
+ /* close the connection */ |
316 |
+ graceful_close(sd,1000); |
317 |
+ |
318 |
+ } |
319 |
|
320 |
/* reset the alarm */ |
321 |
else |
322 |
@@ -434,6 +442,14 @@ int graceful_close(int sd, int timeout){ |
323 |
struct timeval tv; |
324 |
char buf[1000]; |
325 |
|
326 |
+#ifdef HAVE_SSL |
327 |
+ if(use_ssl==TRUE){ |
328 |
+ SSL_shutdown(ssl); |
329 |
+ SSL_free(ssl); |
330 |
+ SSL_CTX_free(ctx); |
331 |
+ } |
332 |
+#endif |
333 |
+ |
334 |
/* send FIN packet */ |
335 |
shutdown(sd,SHUT_WR); |
336 |
for(;;){ |
337 |
diff --git a/src/nrpe.c b/src/nrpe.c |
338 |
index f2b0164..dfa8262 100755 |
339 |
--- a/src/nrpe.c |
340 |
+++ b/src/nrpe.c |
341 |
@@ -972,6 +972,8 @@ void handle_connection(int sock){ |
342 |
char processed_command[MAX_INPUT_BUFFER]; |
343 |
int result=STATE_OK; |
344 |
int early_timeout=FALSE; |
345 |
+ int bytes_copied=0; |
346 |
+ char *pbuffer=&buffer[0]; |
347 |
int rc; |
348 |
int x; |
349 |
#ifdef DEBUG |
350 |
@@ -1188,6 +1190,14 @@ void handle_connection(int sock){ |
351 |
if(buffer[strlen(buffer)-1]=='\n') |
352 |
buffer[strlen(buffer)-1]='\x0'; |
353 |
|
354 |
+ /* Altinity patch to allow multi packet responses */ |
355 |
+ /* Loop not indented to allow easier patching */ |
356 |
+ /* START MULTI_PACKET LOOP */ |
357 |
+ do { |
358 |
+ |
359 |
+ if(debug==TRUE) |
360 |
+ syslog(LOG_DEBUG,"Sending response - bytes left: %d", strlen(pbuffer)); |
361 |
+ |
362 |
/* clear the response packet buffer */ |
363 |
bzero(&send_packet,sizeof(send_packet)); |
364 |
|
365 |
@@ -1196,11 +1206,17 @@ void handle_connection(int sock){ |
366 |
|
367 |
/* initialize response packet data */ |
368 |
send_packet.packet_version=(int16_t)htons(NRPE_PACKET_VERSION_2); |
369 |
- send_packet.packet_type=(int16_t)htons(RESPONSE_PACKET); |
370 |
send_packet.result_code=(int16_t)htons(result); |
371 |
- strncpy(&send_packet.buffer[0],buffer,MAX_PACKETBUFFER_LENGTH); |
372 |
+ strncpy(&send_packet.buffer[0],pbuffer,MAX_PACKETBUFFER_LENGTH); |
373 |
send_packet.buffer[MAX_PACKETBUFFER_LENGTH-1]='\x0'; |
374 |
- |
375 |
+ |
376 |
+ bytes_copied = strlen(&send_packet.buffer[0]); |
377 |
+ pbuffer = pbuffer+bytes_copied; |
378 |
+ if(strlen(pbuffer)>0) |
379 |
+ send_packet.packet_type=(int16_t)htons(RESPONSE_PACKET_WITH_MORE); |
380 |
+ else |
381 |
+ send_packet.packet_type=(int16_t)htons(RESPONSE_PACKET); |
382 |
+ |
383 |
/* calculate the crc 32 value of the packet */ |
384 |
send_packet.crc32_value=(u_int32_t)0L; |
385 |
calculated_crc32=calculate_crc32((char *)&send_packet,sizeof(send_packet)); |
386 |
@@ -1219,6 +1235,9 @@ void handle_connection(int sock){ |
387 |
SSL_write(ssl,&send_packet,bytes_to_send); |
388 |
#endif |
389 |
|
390 |
+ } while (strlen(pbuffer) > 0); |
391 |
+ /* END MULTI_PACKET LOOP */ |
392 |
+ |
393 |
#ifdef HAVE_SSL |
394 |
if(ssl){ |
395 |
SSL_shutdown(ssl); |
396 |
|
397 |
|
398 |
|
399 |
1.1 net-analyzer/nrpe/files/nrpe-nagios3 |
400 |
|
401 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nrpe-nagios3?rev=1.1&view=markup |
402 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/nrpe/files/nrpe-nagios3?rev=1.1&content-type=text/plain |
403 |
|
404 |
Index: nrpe-nagios3 |
405 |
=================================================================== |
406 |
#!/sbin/runscript |
407 |
|
408 |
extra_started_commands="reload" |
409 |
|
410 |
depend() { |
411 |
need net |
412 |
} |
413 |
|
414 |
start() { |
415 |
ebegin "Starting nrpe" |
416 |
start-stop-daemon --start --quiet --name nrpe \ |
417 |
--exec /usr/bin/nrpe \ |
418 |
-c nagios:nagios \ |
419 |
-- -c /etc/nagios/nrpe.cfg \ |
420 |
--daemon |
421 |
eend $? "Failed to Start nrpe" |
422 |
} |
423 |
|
424 |
stop() { |
425 |
ebegin "Stopping nrpe" |
426 |
start-stop-daemon --stop --quiet -n nrpe |
427 |
eend $? "Failed to Stop nrpe" |
428 |
} |
429 |
|
430 |
reload() { |
431 |
ebegin "Reloading nrpe" |
432 |
kill -HUP `pgrep nrpe | head -1` |
433 |
eend $? "Failed to reload nrpe" |
434 |
} |
435 |
|
436 |
restart() { |
437 |
ebegin "Restarting nrpe" |
438 |
svc_stop |
439 |
svc_start |
440 |
eend $? "Failed to Restart nrpe" |
441 |
} |