check_ping returns 0 on failure

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

check_ping returns 0 on failure

Postby gormank » Fri Mar 03, 2017 1:51 pm

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.
gormank
 
Posts: 581
Joined: Tue Dec 02, 2014 12:00 pm

Re: check_ping returns 0 on failure

Postby avandemore » Fri Mar 03, 2017 3:22 pm

Can you show how the host/service is defined? I'd like to take a closer look at this.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
avandemore
Support Tech
 
Posts: 1369
Joined: Tue Sep 27, 2016 4:57 pm
Location: Nagios Enterprises

Re: check_ping returns 0 on failure

Postby gormank » Fri Mar 03, 2017 3:38 pm

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

}
gormank
 
Posts: 581
Joined: Tue Dec 02, 2014 12:00 pm

Re: check_ping returns 0 on failure

Postby avandemore » Mon Mar 06, 2017 2:25 pm

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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
avandemore
Support Tech
 
Posts: 1369
Joined: Tue Sep 27, 2016 4:57 pm
Location: Nagios Enterprises

Re: check_ping returns 0 on failure

Postby gormank » Mon Mar 06, 2017 2:29 pm

Right.
gormank
 
Posts: 581
Joined: Tue Dec 02, 2014 12:00 pm


Return to Nagios Plugin Development

Who is online

Users browsing this forum: No registered users and 3 guests