Nagios XI changing argument at the command line

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nthaler
Posts: 35
Joined: Fri Jul 08, 2016 11:24 am

Nagios XI changing argument at the command line

Post 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.
Last edited by mcapra on Fri Aug 19, 2016 11:33 am, edited 1 time in total.
Reason: please wrap long/technical outputs in [code] tags
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Nagios XI changing argument at the command line

Post 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'
Be sure to check out the Knowledgebase for helpful articles and solutions!
nthaler
Posts: 35
Joined: Fri Jul 08, 2016 11:24 am

Re: Nagios XI changing argument at the command line

Post 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?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios XI changing argument at the command line

Post 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.
You do not have the required permissions to view the files attached to this post.
Former Nagios employee
https://www.mcapra.com/
nthaler
Posts: 35
Joined: Fri Jul 08, 2016 11:24 am

Re: Nagios XI changing argument at the command line

Post 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
	}
Last edited by mcapra on Mon Aug 22, 2016 4:35 pm, edited 1 time in total.
Reason: please wrap long/technical outputs in [code] tags
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Nagios XI changing argument at the command line

Post 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.
Former Nagios employee
https://www.mcapra.com/
nthaler
Posts: 35
Joined: Fri Jul 08, 2016 11:24 am

Re: Nagios XI changing argument at the command line

Post 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.
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Nagios XI changing argument at the command line

Post 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.
Be sure to check out the Knowledgebase for helpful articles and solutions!
Locked