Page 1 of 1

check_mailq issue on localhost

Posted: Thu Jul 19, 2012 9:25 am
by scottjw
Hi,

I am trying to get the check_mailq command working on my Nagios install and not having much luck. I have spent the last two hours googling and not been able to resolve so hoping some kind sole can help.

I am using sendmail and want to check the mail queue on the Nagios localhost (I have issues where my SMTP relay goes offline and alert emails don't get sent).

Using Nagios Core 3.2.3

The command:

Code: Select all

define command{
        command_name    check_mailq
        command_line    $USER1$/check_mailq -w 3 -c 5 -v 9 -M sendmail
}
The service:

Code: Select all

define service {
        use 					generic-service
        host_name               itmonitor
        service_description     SMTP Mail Queue
        check_command           check_mailq
}
From command line as root:

Code: Select all

$ /usr/lib/nagios/plugins/check_mailq -w 3 -c 5 -v 9
OK: mailq is empty|unsent=0;3;5;0
Checking with Nagios user (I think this is right):

Code: Select all

$ su -s /bin/bash nagios -c '/usr/lib/nagios/plugins/check_mailq -w 3 -c 5 -v 9'
OK: mailq is empty|unsent=0;3;5;0
Nagios CGI shows:

Code: Select all

ERROR: is not executable by (uid 1001:gid(1001 1001 1002)) 
From the CGI it suggests the Nagios user doesn't have permissions, but I don't understand why it works from the command line with the Nagios user.

Any advice would be greatly appreciated!

Regards,

Scott

Re: check_mailq issue on localhost

Posted: Thu Jul 19, 2012 9:37 am
by slansing
Could you please do a permissions check just to make sure something strange is going on?

Code: Select all

cd /usr/local/nagios/libexec

Code: Select all

ll
And check back in with the full listing of check_mailq?

Example:

Code: Select all

-rwxrwxrwx  1 nagios nagios  20367 Apr 26 03:37 check_mailq

Re: check_mailq issue on localhost

Posted: Tue Jul 24, 2012 8:25 am
by scottjw
Hi slansing,

ls -l output:

Code: Select all

-rwxr-xr-x 1 nagios nagios  20367 2011-07-01 14:47 check_mailq
Looks different to yours..

Regards,

Scott

Re: check_mailq issue on localhost

Posted: Tue Jul 24, 2012 10:19 am
by nscott
Are you using SELinux or any of its equivalents?

Also, try settings the suid bit:

chown root:root /usr/lib/nagios/plugins/check_mailq
chmod u+s /usr/lib/nagios/plugins/check_mailq

Your current config is using chmod 755, if the suid bit doesn't fix it, you can try

chown nagios.nagcmd /usr/lib/nagios/plugins/check_mailq
chmod 777 /usr/lib/nagios/plugins/check_mailq

Re: check_mailq issue on localhost

Posted: Wed Jul 25, 2012 2:41 am
by scottjw
I'm using Ubuntu 10.04.4 LTS which is fully patched and up to date.

Unfortunately I still have the same result after trying the suid and 777 chmod. Confirmed from the command line again and it still works fine:

Code: Select all

$ su -s /bin/bash nagios -c '/usr/lib/nagios/plugins/check_mailq -w 3 -c 5 -v 9'
OK: mailq is empty|unsent=0;3;5;0