command line check returns OK, GUI returns Warning

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
saiyen2002
Posts: 5
Joined: Thu May 19, 2016 3:49 am

command line check returns OK, GUI returns Warning

Post 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
kiklop
Posts: 7
Joined: Fri May 20, 2011 6:20 am

Re: command line check returns OK, GUI returns Warning

Post 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)
Last edited by rkennedy on Mon Jul 18, 2016 10:41 am, edited 2 times in total.
Reason: Changed $ARG3 to $ARG3$
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: command line check returns OK, GUI returns Warning

Post 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.
Former Nagios Employee
saiyen2002
Posts: 5
Joined: Thu May 19, 2016 3:49 am

Re: command line check returns OK, GUI returns Warning

Post by saiyen2002 »

thanks folks, that did the trick
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: command line check returns OK, GUI returns Warning

Post by mcapra »

Is it alright if we lock this thread and mark the issue as resolved?
Former Nagios employee
https://www.mcapra.com/
Locked