Page 1 of 4

NRPE v.2.15 set maximum output lenght

Posted: Sat Jun 13, 2015 4:32 am
by michaelli
Hi,

I would like to display more log output from check_logfiles. In check_logfiles.cfg, I have set report=long, maxlenght 8192.
I run check_logfiles in client, it can output long log output.

But when I trigger nrpe check_logfiles in nagios, the output is limited to 1024 characters.

I would like to re-compile the nrpe and set a large output buffer. Could you tell me which parameter in common.h I need to set and provide the procedure for compile and installation. Which folder / files I need to backup before install nrpe in nagios server side?

Below is nrpe v2.15 common.h config.

Code: Select all

#define PROGRAM_VERSION "2.15"
#define MODIFICATION_DATE "09-06-2013"

#define OK              0
#define ERROR           -1

#define TRUE            1
#define FALSE           0

#define STATE_UNKNOWN   3       /* service state return codes */
#define STATE_CRITICAL  2
#define STATE_WARNING   1
#define STATE_OK        0


#define DEFAULT_SOCKET_TIMEOUT  10      /* timeout after 10 seconds */
#define DEFAULT_CONNECTION_TIMEOUT 300  /* timeout if daemon is waiting for connection more than this time */

#define MAX_INPUT_BUFFER        2048    /* max size of most buffers we use */
#define MAX_FILENAME_LENGTH     256

#define MAX_HOST_ADDRESS_LENGTH 256     /* max size of a host address */

#define NRPE_HELLO_COMMAND      "_NRPE_CHECK"

#define MAX_COMMAND_ARGUMENTS   16


/**************** PACKET STRUCTURE DEFINITION **********/

#define QUERY_PACKET            1               /* id code for a packet containing a query */
#define RESPONSE_PACKET         2               /* id code for a packet containing a response */

#define NRPE_PACKET_VERSION_3   3               /* packet version identifier */
#define NRPE_PACKET_VERSION_2   2
#define NRPE_PACKET_VERSION_1   1               /* older packet version identifiers (no longer supported) */

#define MAX_PACKETBUFFER_LENGTH 1024            /* max amount of data we'll send in one query/response */

typedef struct packet_struct{
        int16_t   packet_version;
        int16_t   packet_type;
        u_int32_t crc32_value;
        int16_t   result_code;
        char      buffer[MAX_PACKETBUFFER_LENGTH];
        }packet;

/**************** OPERATING SYSTEM SPECIFIC DEFINITIONS **********/
#if defined(__sun) || defined(__hpux)

#  ifndef LOG_AUTHPRIV
#    define LOG_AUTHPRIV LOG_AUTH
#  endif

#  ifndef LOG_FTP
#    define LOG_FTP LOG_DAEMON
#  endif

Re: NRPE v.2.15 set maximum output lenght

Posted: Mon Jun 15, 2015 10:37 am
by jolson
You should be able to modify:

Code: Select all

nrpe/include/common.h
And set the the following two:

Code: Select all

#define MAX_INPUT_BUFFER        xxxx   
#define MAX_PLUGINOUTPUT_LENGTH xxxx
After setting the above appropriately, you should be able to recompile NRPE as you normally would.
Which folder / files I need to backup before install nrpe in nagios server side?
I would backup your nrpe.cfg, xinetd.d/nrpe, check_nrpe, and nrpe binary files.

Code: Select all

cp /usr/local/nagios/etc/nrpe.cfg /root/nrpe.cfg.bak
cp /usr/local/nagios/bin/nrpe /root/nrpe.bak
cp /etc/xinetd.d/nrpe /root/nrpe.xinetd.bak
cp /usr/local/nagios/libexec/check_nrpe /root/check_nrpe.bak

Re: NRPE v.2.15 set maximum output lenght

Posted: Mon Jun 15, 2015 10:39 am
by abrist
I also have a branch with payload size changes:
https://github.com/abrist/nrpe/tree/payload_size
Just remember that you need to update the check_nrpe bin and the remote nrpe daemon for these changes to work.

Re: NRPE v.2.15 set maximum output lenght

Posted: Mon Jun 15, 2015 10:40 am
by ssax
In addition to jolson's changes, I believe you need to change these as well:

Code: Select all

char buf1[XXXX];
char buf2[XXXX];
You can backup these files if you've made changes:

Code: Select all

/usr/local/nagios/etc/nrpe.cfg
/etc/xinetd.d/nrpe

Re: NRPE v.2.15 set maximum output lenght

Posted: Mon Jun 15, 2015 10:52 am
by michaelli
Hi all,

Sorry, should want to confirm. Is this change only reinstall in nagios server side or need to apply both server and client side?

Re: NRPE v.2.15 set maximum output lenght

Posted: Mon Jun 15, 2015 10:58 am
by abrist
You need to update the check_nrpe bin on the nagios server *and* the remote nrpe daemon.

Re: NRPE v.2.15 set maximum output lenght

Posted: Mon Jun 15, 2015 11:03 am
by michaelli
Hi ssax,

If I set as below value.
#define MAX_INPUT_BUFFER 16384
#define MAX_PLUGINOUTPUT_LENGTH 16384

What is the value I should set for buf1,buf2 and where should add below statements. Just after the #define MAX_PLUGINOUTPUT_LENGHT?

char buf1[XXXX];
char buf2[XXXX];

Thanks all for help to solve many nagios questions.

Re: NRPE v.2.15 set maximum output lenght

Posted: Mon Jun 15, 2015 11:08 am
by abrist
You should not have to alter the char1 and char2 buffers. Take a look at the commit on my branch, check_nrpe actually is reverse compatible with older nrpe daemons as it keeps the packet length to 1024, but allows multiple packets to be transmitted up to the maximum MAX_INPUT_BUFFER length:
https://github.com/abrist/nrpe/commit/b ... f0024de6b9

Re: NRPE v.2.15 set maximum output lenght

Posted: Mon Jun 15, 2015 11:22 am
by ssax
abrist is right, sorry about that michaelli.

Just download abrist's branch and compile with that.

Re: NRPE v.2.15 set maximum output lenght

Posted: Mon Jun 15, 2015 11:46 pm
by michaelli
Hi abrist,

I download your nrpe source from your web.
execute ./confgure and make all

copy check_nrpe to nagios server and change owner and permission, restart xinetd service
copy nrpe to client and change owner and permissioin, restart xinetd service

run ./check_nrpe in nagiosxi server

Code: Select all

[root@nagiosxi libexec]# ./check_nrpe -H 172.31.8.198
CHECK_NRPE: Error - Could not complete SSL handshake.
[root@nagiosxi libexec]# ./check_nrpe -H 172.31.8.198 -n
CHECK_NRPE: Error receiving data from daemon.
[root@nagiosxi libexec]# ./check_nrpe -H 172.31.8.198 -n -c check_logfiles
CHECK_NRPE: Error receiving data from daemon.
/var/log/messages in client side.

Code: Select all

Jun 16 12:43:15 gssons02 nrpe[23410]: Error: Could not complete SSL handshake. 5
Jun 16 12:43:18 gssons02 nrpe[23411]: Error: Could not complete SSL handshake. 1
Jun 16 12:43:21 gssons02 nrpe[23413]: Error: Could not complete SSL handshake. 1
Any steps I miss or mistake I taken?