Page 1 of 1

check_smtp | Return code of 127 is out of bounds

Posted: Mon Mar 11, 2019 7:10 am
by steffi
Hi.
When using check_smtp, I am getting this Message:
Return code of 127 is out of bounds - plugin may be missing

When I trigger the check from cli, I get this:
root@mail-2018:~# /usr/lib/nagios/plugins/check_smtp -H localhost --port 25
SMTP OK - 0,043 sec. response time|time=0,042863s;;;0,000000

So I think the Plugin is not missing.
What am I doing wrong?

Thanks,
Steffi

Code: Select all

[define service {
        host_name       localhost
        service_description     smtpd-25
        check_period    24x7
        check_command   check_smtpd_25!localhost|25
        contact_groups  admins
        notification_period     24x7
        initial_state   o
        check_interval  5.000000
        retry_interval  1.000000
        max_check_attempts      4
        is_volatile     0
        parallelize_check       1
        active_checks_enabled   1
        passive_checks_enabled  1
        obsess_over_service     1
        event_handler_enabled   1
        low_flap_threshold      0.000000
        high_flap_threshold     0.000000
        flap_detection_enabled  1
        flap_detection_options  o,w,u,c
        freshness_threshold     0
        check_freshness 0
        notification_options    u,w,c,r
        notifications_enabled   1
        notification_interval   0.000000
        first_notification_delay        0.000000
        stalking_options        n
        process_perf_data       1
        failure_prediction_enabled      1
        retain_status_information       1
        retain_nonstatus_information    1
        }/code]

[code]define command{
        command_name check_smtpd_25
        command_line $USER1$/check_smtp -H $ARG1$ --port $ARG2$
}

Re: check_smtp | Return code of 127 is out of bounds

Posted: Mon Mar 11, 2019 1:12 pm
by tgriep
Couple of things that could cause this.
1. A permission issue. When nagios runs a plugin, it runs it as the nagios user and of the permissions for the plugin are not set for the nagios user, it could generate that error.
To set the permissions, run the following as root.

Code: Select all

chown nagios.nagios /usr/lib/nagios/plugins/check_smtp
chmod a+x /usr/lib/nagios/plugins/check_smtp

2. The command is using the $USER1$ macro for the plugin's path on the file system.
Make sure the $USER1$ macro in the resource.cfg file is set to

Code: Select all

/usr/lib/nagios/plugins/
If not, update it and restart nagios for the change to take effect.

Re: check_smtp | Return code of 127 is out of bounds

Posted: Mon Mar 11, 2019 1:29 pm
by steffi
Thanks for taking care of my issue.
I double checked what you mentionend, but it was all set:

Code: Select all

# Sets $USER1$ to be the path to the plugins
$USER1$=/usr/lib/nagios/plugins

root@mail-2018:~# ll /usr/lib/nagios/plugins/check_smtp 
-rwxr-xr-x 1 root root 72592 Feb  6  2018 /usr/lib/nagios/plugins/check_smtp*
It is not working still.
Steffi

Re: check_smtp | Return code of 127 is out of bounds

Posted: Mon Mar 11, 2019 2:12 pm
by tgriep
Try running the plugin as the nagios user and echo out the status so we can see what it is.
Try running this in a shell. Post the full output.

Code: Select all

su - nagios
/usr/lib/nagios/plugins/check_smtp -H localhost --port 25
echo $?
Thanks.

Re: check_smtp | Return code of 127 is out of bounds

Posted: Mon Mar 11, 2019 3:01 pm
by steffi

Code: Select all

root@mail-2018:~# sudo -u nagios /usr/lib/nagios/plugins/check_smtp -H localhost --port 25 -v
HELOCMD: HELO mail-2018
250 mx18.mx.my.tld
sent QUIT
received 221 2.0.0 Bye

SMTP OK - 0,057 sec. response time, 221 2.0.0 Bye
|time=0,056918s;;;0,000000

Re: check_smtp | Return code of 127 is out of bounds

Posted: Mon Mar 11, 2019 3:41 pm
by npolovenko
@steffi, In the service definition that you posted you have | sign instead of ! dividing arguments. Look at the line:
check_command check_smtpd_25!localhost|25
You need to replace |with !
check_command check_smtpd_25!localhost!25

Code: Select all

define service {
        host_name       localhost
        service_description     smtpd-25
        check_period    24x7
        check_command   check_smtpd_25!localhost|25
        contact_groups  admins
        notification_period     24x7
        initial_state   o
        check_interval  5.000000
        retry_interval  1.000000
        max_check_attempts      4
        is_volatile     0
        parallelize_check       1
        active_checks_enabled   1
        passive_checks_enabled  1
        obsess_over_service     1
        event_handler_enabled   1
        low_flap_threshold      0.000000
        high_flap_threshold     0.000000
        flap_detection_enabled  1
        flap_detection_options  o,w,u,c
        freshness_threshold     0
        check_freshness 0
        notification_options    u,w,c,r
        notifications_enabled   1
        notification_interval   0.000000
        first_notification_delay        0.000000
        stalking_options        n
        process_perf_data       1
        failure_prediction_enabled      1
        retain_status_information       1
        retain_nonstatus_information    1
        }

Re: check_smtp | Return code of 127 is out of bounds

Posted: Tue Mar 12, 2019 2:54 am
by steffi
Wow. I was too blind to see.
Thank you so much| :-) It is working| :-)
Steffi

Re: check_smtp | Return code of 127 is out of bounds

Posted: Tue Mar 12, 2019 8:51 am
by scottwilkerson
steffi wrote:Wow. I was too blind to see.
Thank you so much| :-) It is working| :-)
Steffi
Great!

Locking thread