Page 1 of 1

check_ping returns 0 on failure

Posted: Fri Mar 03, 2017 1:51 pm
by gormank
Yes, its unreasonable to have a completely wrong address, but returning success on a failure is also unreasonable. To explain a bit, when check_ping is running on the host in Nagios, I see the following, and the host is green. The issue is with the host showing up when it isn't.

(No output on stdout) stderr: /bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `/usr/local/nagios/libexec/check_ping -H (iLO) 2001:4888:a05:3152:e0:ff2::403 -w 3000.0,80% -c 5000.0,100% -p 5'

When I run in the shell, I get the following:

# /usr/local/nagios/libexec/check_ping -H (iLO) 2001:4888:a05:3152:e0:ff2::403 -w 3000.0,80% -c 5000.0,100% -p 5'
-bash: syntax error near unexpected token `('
# echo $?
2

The host check command is check_icmp, which runs check_ping, and the system is 5.4.0
This is just an FYI and this can be closed.

Re: check_ping returns 0 on failure

Posted: Fri Mar 03, 2017 3:22 pm
by avandemore
Can you show how the host/service is defined? I'd like to take a closer look at this.

Re: check_ping returns 0 on failure

Posted: Fri Mar 03, 2017 3:38 pm
by gormank
Sure, but its a bit convoluted since the hosts use a template that uses yet another template. The host config was generated from a csv file using a script. The host config files were then imported by dumping them into the import dir. Beats creating >260 hosts by hand.

The address has (iLO) in it that came from the original Excel and obviously doesn't belong there. I just grepped the string in the host cfg files, copied the ones that had it to the import dir, used sed to get rid of the nonsense and ran reconfigure_nagios.sh to re-import.

You should be able to reproduce the issue by putting a ( in the address and make a host check using check_ping.

One other bit of trivia in 5.4.0 is in CCM, if you go to the bottom in say, services, and select none in the results per page dropdown, it does nothing, where it used to put all results in one page...

Code: Select all

define host {
        host_name                       clspcoykhsc-h-peeesxw-03
        use                             1VZW_default_host
        alias                           ESX Host
        address                         (iLO) 2001:4888:a05:3152:e0:ff2::403
        register                        1
        }

Code: Select all

define host {
       name                                     base_host
       alias                                    Template containing notification and check intervals. Used by templates
       check_command                            check_icmp!3000.0,80%!5000.0,100% -p 5!!!!!!
       max_check_attempts                       4
       check_interval                           5
       retry_interval                           1
       check_period                             24x7
       event_handler_enabled                    1
       flap_detection_enabled                   1
       process_perf_data                        1
       retain_status_information                1
       retain_nonstatus_information             1
       notification_interval                    60
       notification_period                      24x7
       first_notification_delay                 15
       register                                 0

}

Code: Select all

define host {
       name                                     default_host
       alias                                    Template for most hosts
       use                                      1VZW_base_host
       flap_detection_enabled                   1
       process_perf_data                        1
       retain_status_information                1
       retain_nonstatus_information             1
       notification_interval                    60
       first_notification_delay                 15
       notification_options                     d,u,f,
       notifications_enabled                    1
       register                                 0

}

Re: check_ping returns 0 on failure

Posted: Mon Mar 06, 2017 2:25 pm
by avandemore
One other bit of trivia in 5.4.0 is in CCM, if you go to the bottom in say, services, and select none in the results per page dropdown, it does nothing, where it used to put all results in one page...
Known bug, fixed in current versions.

Regarding the original issue, it's easier to understand this if you think of Nagios object definitions as parameters to CLI invocations. So things like "(" are going to have their inherent issues when used. However even if you properly escaped it, it's still an invalid definition that would have broken elsewhere. The address field must only contain a single resolvable address.

Re: check_ping returns 0 on failure

Posted: Mon Mar 06, 2017 2:29 pm
by gormank
Right.