Page 1 of 1

Nagios XI changing argument at the command line

Posted: Fri Aug 19, 2016 11:29 am
by nthaler
Hi,

I am attempting to run the following command in XI v5.2.9

$USER1$/check_http -H $ARG1$ -t 50 -u $ARG2$ -R $ARG3$ the expanded command with arguments filled in is below

Code: Select all

/usr/local/nagios/libexec/check_http -H neoreviews.aappublications.org -t 50 -u /content/17/8?current-issue=y/cgi/search?sendit=Search&pubdate_year=&volume=&firstpage=&author1=&author2=Frank&title=&andorexacttitle=and&titleabstract=&andorexacttitleabs=and&fulltext=&andorexactfulltext=and&SITESECTION=vj&fmonth=Jan&fyear=2000&tmonth=Oct&tyear=2006&fdatedef=1+January+2000&tdatedef=1+October+2006&flag=&RESULTFORMAT=1&hits=10&hitsbrief=25&sortspec=relevance&sortspecbrief=relevance -R Cocaine
When I test it from the UI what is says it is actually sending is

/usr/local/nagios/libexec/check_http -H neoreviews.aappublications.org -t 50 -u /content/17/8\?current-issue=y/cgi/search\?sendit=Search -R Cocaine

I get back OUTPUT: HTTP CRITICAL: HTTP/1.1 200 OK - pattern not found - 73039 bytes in 0.475 second response time |time=0.474661s;;;0.000000 size=73039B;;;0

but if I run the command with the full arguments from the command line I get the following output.
HTTP OK: HTTP/1.1 200 OK - 73039 bytes in 0.366 second response time |time=0.365756s;;;0.000000 size=73039B;;;0
which is what I expect to see.

Why is Nagios XI changing my arguments that have been input through the UI?

I have this issue on several checks that use the same syntax.

Re: Nagios XI changing argument at the command line

Posted: Fri Aug 19, 2016 11:42 am
by bwallace
The 'test check command' button executes very differently than from how Nagios does natively and is known to escaping issues with certain checks. Have you tried just configuring the check, and then applying configuration and allowing XI to perform the check normally?

Test Check Command button = run as 'apache'
XI normally running check = run as 'nagios'

Re: Nagios XI changing argument at the command line

Posted: Mon Aug 22, 2016 4:05 pm
by nthaler
I have allowed this check to run normally. When I let it run normally I get HTTP CRITICAL: HTTP/1.1 200 OK - pattern not found - 73947 bytes in 0.458 second response time.

When I run it from the command line I get. HTTP OK: HTTP/1.1 200 OK - 73039 bytes in 0.479 second response time |time=0.479493s;;;0.000000 size=73039B;;;0

They are essentially the same but one returns CRITICAL and the other OK.

To me it seems to have something to do with ? within an Argument. Does something in XI not like ? in arguments?

Re: Nagios XI changing argument at the command line

Posted: Mon Aug 22, 2016 4:17 pm
by mcapra
Can you show us the full definition for this particular service check? You can access this from the Core Config Manager by clicking the floppy-disk icon. ? is a reserved character in bash, so we may need to modify this definition by hand.

Re: Nagios XI changing argument at the command line

Posted: Mon Aug 22, 2016 4:35 pm
by nthaler
Sure.

Code: Select all

define service {
	host_name			hwmaint24
	service_description		Home Page - neoreviews - Author Search - neoreviews.aappublications.org
	use				generic-service
	servicegroups			aappub-journal-services,H10-services
	check_command			check_url_content_match!neoreviews.aappublications.org!/content/17/8?current-issue=y/cgi/search?sendit=Search&pubdate_year=&volume=&firstpage=&author1=&author2=Frank&title=&andorexacttitle=and&titleabstract=&andorexacttitleabs=and&fulltext=&andorexactfulltext=and&SITESECTION=vj&fmonth=Jan&fyear=2000&tmonth=Oct&tyear=2006&fdatedef=1+January+2000&tdatedef=1+October+2006&flag=&RESULTFORMAT=1&hits=10&hitsbrief=25&sortspec=relevance&sortspecbrief=relevance!Cocaine!!!!!
	contacts			setup
	register			1
	}

Re: Nagios XI changing argument at the command line

Posted: Mon Aug 22, 2016 4:43 pm
by mcapra
For starters, I would change your command definition to wrap the string arguments in quotes like so:

Code: Select all

$USER1$/check_http -H $ARG1$ -t 50 -u '$ARG2$' -R '$ARG3$'
Also to clarify, are you expecting "Cocaine" to appear on this page or would you like to be alerted if "Cocaine" appears? If you ARE expecting Cocaine to be on this page, -R by itself should be fine. If you ARE NOT expecting Cocaine to be on this page, try adding --invert-regex to the parameters of this check.

Re: Nagios XI changing argument at the command line

Posted: Thu Aug 25, 2016 1:48 pm
by nthaler
I think I we have this figured out, some of it was the version of check_http. We are upgrading to XI and the version core 2 was using was returning slightly different results.

Thank you for the help.

Re: Nagios XI changing argument at the command line

Posted: Thu Aug 25, 2016 1:50 pm
by bwallace
Thanks for that update, I'll go ahead and lock this thread now. Feel free to open a new thread if you have any other questions.