Problem with check_mailq and sudo

Hello everyone,

I have created the check mail queue in the Icinga Director with the existing mailq command. In addition, I have activated the parameter for sudo. The command is also executed correctly on the server to be checked. Under Inspect I see

'/usr/lib/nagios/plugins/check_mailq' '-c' '20' '-s' '-w' '10'

So far so good. But the problem is: The check is of course negative, because the sudo fails. I have already tried all possible sudo rules but can’t find the right one. Currently I have:

nagios ALL=(root) NOPASSWD:/usr/lib/nagios/plugins/check_mailq *

Can someone give me the crucial tip where it hangs?

change the command from



sudo /usr/lib/nagios/plugins/check_mailq

you can also do this my importing the old command and overwriting the command field.
after that you use your new command in the service template

object CheckCommand "sudo_check_mailq" {
    import "name_of_check_mailq"
    command = [ "/usr/bin/sudo", "/usr/lib/nagios/plugins/check_mailq"]


thanks for your reply. I thought there is a solution to use the -s switch, but this solution is much more easier and for sure it is working like expected.

Thanks and have a nice weekend!