Page 1 of 1

command line check returns OK, GUI returns Warning

Posted: Mon Jul 18, 2016 3:54 am
by saiyen2002
I am using Nagios Core 3.5.1 on Ubuntu 14.04.2 LTS.

I have created a http check for a site and tested on the command line which returns me OK status. I am expecting a http 400 and body to be 'Malformed'

Code: Select all

# /usr/lib/nagios/plugins/check_http --ssl -H example.co.uk -u /rpc/json.php -s 'Malformed' -e 400
HTTP OK: Status line output matched "400" - 399 bytes in 0.050 second response time |time=0.049943s;;;0.000000 size=399B;;;0
I then put that into the actual nagios configuration and it returns me a warning. Below is my command config and service config.

Code: Select all

define command{
        command_name    check_custom_https_path
        command_line    /usr/lib/nagios/plugins/check_http --ssl -H '$ARG1$' -u '$ARG2$'
        }

define service {
        use                             generic-service,graphed-service
        host_name                       localhost
        service_description             Check example.co.uk
        check_command                   check_custom_https_path!example.co.uk!/rpc/json.php!-s 'Malformed'!-e 400!-w 1!-c 2
        contact_groups                  admins
}
these the actual status information for the check that I get on the UI is

Status Information: HTTP WARNING: HTTP/1.1 400 Bad Request - 399 bytes in 0.074 second response time

This does not make sense since i have put the -e 400 switch saying I am expecting the 400 Bad Request.

any suggestions?

thanks

Re: command line check returns OK, GUI returns Warning

Posted: Mon Jul 18, 2016 7:30 am
by kiklop
Hi,

in command you have ARG1 & ARG2 but in service you are passing more arguments.. Also dont use quotes for this in command def.

Didnt test it but, it should be something like this :

Code: Select all

 /usr/lib/nagios/plugins/check_http --ssl -H example.co.uk -u /rpc/json.php -s 'Malformed' -e 400

define command{
        command_name    check_custom_https_path
        command_line    /usr/lib/nagios/plugins/check_http --ssl -H $ARG1$ -u $ARG2$ -s $ARG3$ -e 400 -w 1 -c 2
        }

define service {
        use                             generic-service,graphed-service
        host_name                       localhost
        service_description             Check example.co.uk
        check_command                   check_custom_https_path!example.co.uk!/rpc/json.php!Malformed
        contact_groups                  admins
}
If you are not sure, lets start with this procedure :
- Define command without arguments, just copy working command from command line and create a copy in nagios command definitions. Then assign command to service and test (should works)
- lets try to replace strings in command and add arguments one by one, at first replace -H with $ARG1$ and modify check_command for service (add !server_address)

Re: command line check returns OK, GUI returns Warning

Posted: Mon Jul 18, 2016 10:37 am
by rkennedy
Thanks @kiklop! You are correct.

@saiyen2002 - as @kiklop mentioned, looks like you're missing additional $ARG$ values. His answer will work.

Alternatively, you could just change your command_line in the command definition to include $ARG3$, $ARG4$, $ARG5$, and $ARG6$. You're able to pass the variables how you want. The minimalist way is what @kiklop mentioned though.

Re: command line check returns OK, GUI returns Warning

Posted: Thu Jul 21, 2016 6:08 am
by saiyen2002
thanks folks, that did the trick

Re: command line check returns OK, GUI returns Warning

Posted: Thu Jul 21, 2016 9:47 am
by mcapra
Is it alright if we lock this thread and mark the issue as resolved?