[Nagios-devel] check_nrpe parses arguments to -a (with fix)

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] check_nrpe parses arguments to -a (with fix)

Post by Guest »

check_nrpe parses arguments to the -a option, which it
shouldn't, since those args are for the remote plugin,
not for check_nrpe itself.

Repeat by:
/usr/local/libexec/nagios/check_nrpe -H one -c hello -a there -V
which will likely complain about -V being invalid.

I ran into this when I was trying to do an indirect check_http:
check_nrpe -H gatehost -c check_http -H webhost
and noticed that check_nrpe was trying to connect to webhost
and not gatehost.

Here's a quick diff to src/check_nrpe.c that stops parsing args
once it finds -a, and also adds the -V option to the getopt args.

Thanks - cheers!

John


*** check_nrpe.c.2.12 Wed Apr 9 01:51:12 2008
--- check_nrpe.c Wed Apr 9 01:53:30 2008
***************
*** 328,333 ****
--- 328,334 ----
{"port", required_argument, 0, 'p'},
{"help", no_argument, 0, 'h'},
{"license", no_argument, 0, 'l'},
+ {"version", no_argument, 0, 'V'},
{0, 0, 0, 0}
};
#endif
***************
*** 336,342 ****
if(argc<2)
return ERROR;

! snprintf(optchars,MAX_INPUT_BUFFER,"H:c:a:t:p:nuhl");

while(1){
#ifdef HAVE_GETOPT_LONG
--- 337,343 ----
if(argc<2)
return ERROR;

! snprintf(optchars,MAX_INPUT_BUFFER,"H:c:a:t:p:nuhlV");

while(1){
#ifdef HAVE_GETOPT_LONG
***************
*** 389,394 ****
--- 390,399 ----
return ERROR;
break;
}
+ if(c=='a'){
+ /* -a must be last arg; avoid parsing -a args */
+ break;
+ }
}

/* determine (base) command query */





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