2

Nagios 4.1.1 Ubuntu 14.04 x64

Please note This is a new server. Our old Nagios server has this EXACT SAME config but on version 3 on RHEL, and it works.

I have a custom command to check an OpenVPN Server external connectability:

define command{
    command_name        check_udp_openvpn
    command_line        $USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$ -s "$38$01$00$00$00$00$00$00$00" -e ""
}

$USER1$ points to /usr/local/nagios/libexec and it is the same for all my command declarations.

If I run it as ROOT: PASS

/usr/local/nagios/libexec/check_udp -H vpn.myhost.com -p 43963 -s "$38$01$00$00$00$00$00$00$00" -e ""

UDP OK - 0.003 second response time on vpn.myhost.com port 43963 [@¬è«ÿï]|time=0.003033s;;;0.000000;10.000000

If I run as sudo - nagios: PASS

su - nagios -c "/usr/local/nagios/libexec/check_udp -H vpn.myhost.com -p 43963 -s "$38$01$00$00$00$00$00$00$00" -e \"\""

UDP OK - 0.003 second response time on vpn.myhost.com port 43963 [@õq-Û¸]|time=0.002951s;;;0.000000;10.000000

If ran as an active check: FAIL

So, everything works perfectly from the command line, however, in Nagios console, it fails!

Check OpenVPN Fail

Here is how it's declared in the host:

define host{
    host_name                    vpn.myhost.com
    alias                        vpn.myhost.com
    address                      vpn.myhost.com
    check_command                check_udp_openvpn!43963
    check_interval               5
    retry_interval               1
    max_check_attempts           5
    check_period                 24x7
    process_perf_data            0
    retain_nonstatus_information 0
#   contacts                     nobody
    contact_groups               sysadmins
#   2d_coords                    10,10
    notification_interval        30
    notification_period          24x7
    notification_options         d,u,r
    hostgroups                   web
}

EDIT:

I've also tried setting the host definition to a standard ping check, and put in a service definition for the check_upd_openvpn command.

The host shows UP but the service is DOWN. Same exact error "Socket timeout after 10 seconds" -- The command line use is nearly instant with the UDP OK return. I am stumped.

EDIT 2:

I tweaked the debug settings, and have turned logging verbosity up to the highest value (2). It doesn't really tell me much, but it looks like Nagios is interpreting the command as expected...

[1460412294.994325] [256.1] [pid=21652] Read raw external command '[1460412294] SCHEDULE_FORCED_SVC_CHECK;vpn.myhost.com;OpenVPN Service;1460412293'
[1460412294.994418] [2320.2] [pid=21652] Raw Command Input: $USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$ -s "$38$01$00$00$00$00$00$00$00" -e ""
  • Do you have macros enabled in nagios.cfg enable_environment_macros=1? – Diamant Apr 8 '16 at 10:03
  • I would check with tcpdump or tshark that the UDP packet you are sending is the same. Working on the command line but not live is often some sort of escaping problem. – richardb Apr 8 '16 at 12:05
  • 1
    This sounds like part of the UDP string $38$01$00$00$00$00$00$00$00 getting replaced from Nagios, because its also the macro operator, Icinga has a feature called keep_unknown_macros - but I don't know how Nagios 4 handles this – lazyfrosch Apr 8 '16 at 15:08
  • @lazyfrosch yes I am currently experimenting with escape charters and even adding the value into the USERx variables for Nagios use. Will report back when I have done some experimentation. The crazy thing is that it worked fine in Nagios3 – emmdee Apr 8 '16 at 21:51
  • @bangal -- Yes I have it set in nagios.cfg enable_environment_macros=1 thanks – emmdee Apr 8 '16 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.