Enter edit mode for sudoers.


Add the following at the bottom.

Defaults:nagios !requiretty
nagios ALL = NOPASSWD: /usr/sbin/exim

And thats that.

Some explanation.

Normally   defaults requiretty  is set earlier in the file, which stops sudo from running while not under a tty (shell) we override this for nagios user by setting   defaults:nagios !requiretty as showed over.

Visudo is a command for opening /etc/sudoers in your distros default editor.

NOPASSWD does so command does’nt need password to run sudo.