NRPE v.2.15 set maximum output lenght

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
michaelli
Posts: 115
Joined: Thu Jan 29, 2015 11:21 am

NRPE v.2.15 set maximum output lenght

Post 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
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: NRPE v.2.15 set maximum output lenght

Post 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
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: NRPE v.2.15 set maximum output lenght

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: NRPE v.2.15 set maximum output lenght

Post 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
michaelli
Posts: 115
Joined: Thu Jan 29, 2015 11:21 am

Re: NRPE v.2.15 set maximum output lenght

Post 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?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: NRPE v.2.15 set maximum output lenght

Post by abrist »

You need to update the check_nrpe bin on the nagios server *and* the remote nrpe daemon.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
michaelli
Posts: 115
Joined: Thu Jan 29, 2015 11:21 am

Re: NRPE v.2.15 set maximum output lenght

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: NRPE v.2.15 set maximum output lenght

Post 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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: NRPE v.2.15 set maximum output lenght

Post by ssax »

abrist is right, sorry about that michaelli.

Just download abrist's branch and compile with that.
michaelli
Posts: 115
Joined: Thu Jan 29, 2015 11:21 am

Re: NRPE v.2.15 set maximum output lenght

Post 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?
Locked