[Nagios-devel] MAX_PLUGINOUTPUT_LENGTH limits for Nagios 2.x

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] MAX_PLUGINOUTPUT_LENGTH limits for Nagios 2.x

Post by Guest »

Hello all,

I have noticed that a number of fellow Nagios users have requested
larger service check output. I also have this requirement.

While Nagios 3.x will remove the service check output limit we could
have a reasonable solution now. Below is a patch I hope will be considered
for the 2.x branch.

I believe that the patch has the following benefits.

1) MAX_PLUGINOUTPUT_LENGTH is calculated to use the largest value
reasonable for the computer it is compiled on. This increases service check
output limit to just under 4k on Linux, more for Solaris.
2) Some compilers use struct padding to speed up access to variables
in structures
(gcc for one). struct service_message_struct has been reordered to
avoid this.


Ethan is it possible to get this patch in? If you have any issues with the
coding of it I would be happy to redo the patch as required.

Regards,
Danny Reynolds


p.s. The patch below is for Nagios 2.6.1 from the RPM repository DAG.



Index: nagios/include/common.h
===================================================================
RCS file: /local/noc/cvs/nagios/nagios/include/common.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 common.h
--- nagios/include/common.h 21 Dec 2006 02:53:21 -0000 1.1.1.1
+++ nagios/include/common.h 10 Jan 2007 21:55:04 -0000
@@ -378,8 +378,33 @@

/************************** MISC DEFINITIONS ****************************/

-#define MAX_FILENAME_LENGTH 256 /* max length of
path/filename that Nagios will process */
+
+/*
+Work out the best size for MAX_PLUGINOUTPUT_LENGTH.
MAX_PLUGINOUTPUT_LENGTH
+is calculated below to make sure that struct service_message_struct
+is smaller than PIPE_BUF for your system. This stops service check
results from
+being mangled when going through internal pipes, yet still allowing
+modern POSIX systems to have a decently large MAX_PLUGINOUTPUT_LENGTH.
+
+MAX_INPUT_BUFFER is used for writing out perfdata (amoungst other things).
+it must be the same size or larger than MAX_PLUGINOUTPUT_LENGTH.
+
+NOTE: The '+ 20' at the end is a kludge to avoid problems due to
+struct padding under some compilers (GCC for one). See
+http://www.delorie.com/djgpp/v2faq/faq22_11.html for the gruesome details.
+*/
+#include
+#include
+
+#ifdef PIPE_BUF
+#define MAX_PLUGINOUTPUT_LENGTH (PIPE_BUF -
(MAX_HOSTNAME_LENGTH + MAX_SERVICEDESC_LENGTH + sizeof(int) * 5 +
sizeof(struct timeval) * 2 + 20)) /* max. length of plugin output */
+#define MAX_INPUT_BUFFER (1024 + MAX_PLUGINOUTPUT_LENGTH)
/* size in bytes of max. input buffer (for reading files) */
+#else
+#define MAX_PLUGINOUTPUT_LENGTH 332 /* max. length of
plugin output */
#define MAX_INPUT_BUFFER 1024 /* size in bytes of max.
input buffer (for reading files) */
+#endif
+
+#define MAX_FILENAME_LENGTH 256 /* max length of
path/filename that Nagios will process */
#define MAX_COMMAND_BUFFER 8192 /* max length
of raw or processed command line */

#define MAX_DATETIME_LENGTH 48
Index: nagios/include/nagios.h.in
===================================================================
RCS file: /local/noc/cvs/nagios/nagios/include/nagios.h.in,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 nagios.h.in
--- nagios/include/nagios.h.in 21 Dec 2006 02:53:21 -0000 1.1.1.1
+++ nagios/include/nagios.h.in 10 Jan 2007 21:28:08 -0000
@@ -391,8 +391,6 @@

/* SERVICE_MESSAGE structure */
typedef struct service_message_struct{
- char host_name[MAX_HOSTNAME_LENGTH]; /* host name */
- char description[MAX_SERVICEDESC_LENGTH]; /* service description */
int return_code; /* plugin return code */
int exited_ok; /* did the plugin check return
okay? */
int check_type; /* was this an active or passive
service check? */
@@ -401,6 +399,8 @@
struct timeval finish_time; /* time the service check
was completed */
int early_timeout; /* did the service
check timeout? */
char output[MAX_

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked