Now I am done with my first very basic Nagios configuration which means that I passed the Nagios configurationtest without any warnings or errors.
Now I need to know, how I can use a mail-relay from my Linux-box.
The box is placed in a DMZ and has an IP of 192.168.0.5. The IP 192.168.0.4 holds a machine where a mailrelay is running that would accept mails from 192.168.0.5. Now my problem is that I do not have any idea what to do. Probably I need postfix or anything to forward?
Can someone help me please?
The idea is that Nagios is able to send mails by using the mailx-command and those mails should be forwarded to 192.168.0.4 which will manage the ongoing transport of the mail.
You don’t need postfix for this. mailx can talk directly to a SMTP server if you set the smtp variable in the config file ~/.mailrc. See man mailx for the details.
I tried to send mails via shell-command mailx/mail as root which works fine. But my nagios-installation does not send any mails.
I think I know that the reason is that the user nagios does not use root’s .mailrc. So what I did was to generate a home-dir for nagios (/home/nagios) where I stored the same file as I did it for root. But this seems not work.
FOOBAR:~ # ls -al /home/nagios/
total 12
...
-rw-r--r-- 1 nagios nagios 45 Oct 30 16:52 .mailrc
When I tried a su nagios, it does not work. I did not get an error, but the user is not switched:
Have a lot of fun...
FOOBAR:~ # su nagios
FOOBAR:~ # whoami
root
FOOBAR:~ #
So what is the trick to get the configuration that is stored in the .mailrc working for the nagios-user=?