Page 1 of 2

check_mailq | Service check did not exit properly

Posted: Mon Mar 11, 2019 6:59 am
by steffi
Hi.
One of my remote servers to check is using the check_mailq service check.
I am on Ubuntu 18.04 using postfix.
My service check result is: (Service check did not exit properly).

What am I doing wrong?
Thanks,
Steffi

Code: Select all

define service {
        host_name       localhost
        service_description     mailq
        check_period    24x7
        check_command   check_mailqueue!100!200
        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_mailq | Service check did not exit properly

Posted: Mon Mar 11, 2019 2:14 pm
by lmiltchev
Can you show us the actual check run from the command line along with the output of it? Please add "-v" to the command (for verbose mode/debugging output).

Re: check_mailq | Service check did not exit properly

Posted: Mon Mar 11, 2019 2:56 pm
by steffi

Code: Select all

root@mail-2018:~# sudo -u nagios /usr/lib/nagios/plugins/check_mailq -w 10 -c 20 -v
OK: postfix mailq reports queue is empty|unsent=0;10;20;0

Re: check_mailq | Service check did not exit properly

Posted: Mon Mar 11, 2019 3:29 pm
by npolovenko
@steffi, Thank you. I would like to see how the check_mailqueue command is defined on your Nagios server.
The command is most likely located in this file:
/usr/local/nagios/etc/objects/commands.cfg

Re: check_mailq | Service check did not exit properly

Posted: Tue Mar 12, 2019 3:29 am
by steffi
Hi.
Thanks for your support. This is the command definition:

Code: Select all

define command{
        command_name check_mailqueue
        command_line $USER1$/check_mailq  -w '$ARG1$' -c '$ARG2$' -M postfix
}

Re: check_mailq | Service check did not exit properly

Posted: Tue Mar 12, 2019 8:53 am
by scottwilkerson
So based on this command your server would run the following, can you run it from the command line?

Code: Select all

sudo -u nagios /usr/lib/nagios/plugins/check_mailq -w 10 -c 20 -M postfix

Re: check_mailq | Service check did not exit properly

Posted: Tue Mar 12, 2019 9:44 am
by steffi
Hi Scott.
This is the output:

Code: Select all

root@mail-2018:~# sudo -u nagios /usr/lib/nagios/plugins/check_mailq -w 10 -c 20 -M postfix
OK: postfix mailq reports queue is empty|unsent=0;10;20;0

Re: check_mailq | Service check did not exit properly

Posted: Tue Mar 12, 2019 9:57 am
by scottwilkerson
Per the plugin help

Code: Select all

This plugin uses the system mailq command (sendmail) or qmail-stat (qmail)
 to look at the queues. Mailq can usually only be accessed by root or
 a TrustedUser. You will have to set appropriate permissions for the plugin to work.
So your command would need to be prefixed with sudo

Code: Select all

define command{
        command_name check_mailqueue
        command_line sudo $USER1$/check_mailq  -w '$ARG1$' -c '$ARG2$' -M postfix
}
and you would need to add the appropriate line to your sudoers file allowing the nagios user sudo access to

Code: Select all

nagios ALL = NOPASSWD:/usr/lib/nagios/plugins/check_mailq *

Re: check_mailq | Service check did not exit properly

Posted: Tue Mar 12, 2019 10:45 am
by steffi
Ah, thanks.
This is what I did with the check_udp_port plugin also which uses nmap.

Will try.
Thanks.

Re: check_mailq | Service check did not exit properly

Posted: Tue Mar 12, 2019 10:45 am
by scottwilkerson
steffi wrote:Ah, thanks.
This is what I did with the check_udp_port plugin also which uses nmap.

Will try.
Thanks.
Let us know if you have further questions