check_nrpe parses arguments to -a (with fix)
John Sellens
jsellens at syonex.com
Wed Apr 9 08:00:55 CEST 2008
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 SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
More information about the Developers
mailing list