Solved! (Re: No e-mail notifications with new 2.5 install on Debian Etch)

Samuel P Howard nagios at GMxTechnologies.com
Fri Aug 11 19:51:55 CEST 2006


OK, I've gotten no response, but I have done some more digging in the 
meantime ... here's what I've found:

I changed the notify-by-email to this:

    /usr/bin/mutt -s "test" someone at something.com </dev/null 2>&1 | tee 
-a /tmp/notice.log

And checked /tmp/notice.log:

    /root/sent: Permission denied (errno = 13)
    /root/sent: Permission denied (errno = 13)
    Could not send the message.

AH HA!

So, digging more ...

    # ps -ef e | grep nagios

    nagios   20979     1  0 12:14 ?        Ssl    0:00
    /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
    SHELL=/bin/bash TERM=xterm SSH_CLIENT=xxxxxxxxx 2139 22
    SSH_TTY=/dev/pts/0 USER=root
    SSH_AUTH_SOCK=/tmp/ssh-WGnUfb1218/agent.1218
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
    MAIL=/var/mail/root PWD=/usr/local/nagios/etc HOME=/root SHLVL=2
    LOGNAME=root SSH_CONNECTION=xxxxxxxx 2139 xxxxxxx 22
    _=/usr/local/nagios/bin/nagios

Ummm...wait ... if this is running as user "nagios", why the heck is the 
HOME=/root, LOGNAME=root, etc?  And we dig deeper.

I see in /etc/init.d/nagios (created by the installer) that it does a 
"su - nagios" to touch (create) a log file and another file it needs, 
but then it calls the nagios binary directly as root.  I see in 
.../base/utils.c, the binary does a setuid(), but doesn't do anything to 
reset the environment, so it is just inheriting it from the calling user 
(in this case root).

So, why are other people not having problems with notifications if their 
nagios daemon is running with root's environment?  I am guessing it is 
because I am using mutt and not mail/mailx to do the notifications, and 
mutt is trying to save the outgoing e-mail (which would be bad anyway).

There are three obvious solutions for this:

1 - switch to mailx (in my case, apt-get install mailx, replace "mutt" 
with 'mailx" in the notify-by-email commands).
2 - add "set copy=no" to /etc/Muttrc to disable the e-mail copy 
feature.  I couldn't find a way to do it via the command line, and I 
*could* have put it in /root/.muttrc, except the nagios user won't be 
able to read the file, and therefore won't pick up the configuration.  
WARNING: This option affects all users systemwide, unless they 
re-override it in *their* ~/.muttrc.  In my case, there are really no 
"users" on this box, just apps and services, so it's OK for me.
3 - create a "muttrc" somewhere that nagios can reach (i.e. 
/usr/local/nagios/etc/muttrc) and add "-F /usr/local/nagios/etc/muttrc" 
to the mutt command in the notify-by-email command

I have done 1 and 3, actually.  I installed mail/mailx just because 
other apps might just assume it's there (why it wasn't originally, I'm 
not sure), and I created the /usr/local/nagios/etc/Muttrc, too.

So, why do I prefer mutt over mailx for sending mail?  Basically, just 
because I like mutt's ability to easily attach files as attachments 
without having to manually deal with uuencode and friends.

OK, with this data dump, I am back on the air and back to working on a 
strategy to configure my nagios server to monitor everything else in the 
world.  I've very interested in watching the thread by Fred Clausen develop!

Thanks,
Sam

Samuel P Howard wrote:
> Hi.
>
> I noticed a recent thread by Marcos Marinho having what sounds like a 
> similar problem, but no solution yet ...
>
> I have just built from source and installed Nagios 2.5 on a Debian Etch 
> (testing) server, and when I cause a fault, the nagios.log shows it 
> triggers the notification-by-email, but yet the /var/log/mail.info does 
> not show postfix firing up to send the mail out.
>
> I did notice that the command setup in minimal.cfg (what I am playing 
> with now, the other command files are disabled) did not put in a mail 
> client, as I did not have one installed.  I installed mutt, and added it 
> to the command line after the | and before the -s, and also redirected 
> the output of the command to a text file and (spacing aside), it looked 
> OK.  I'm not sure if the spacing should have been compressed or not, so 
> that is a good question.
>
> Running the command manually as root or as nagios, I do get an e-mail 
> (as long as I manually replace the $CONTACTEMAIL$ to a real email 
> address ... obviously, none of the other variables get expanded, but the 
> mail does flow.
>
> Is there some way to turn on additional debugging to see if the nagios 
> daemon is failing on the command somewhere???
>
> Notificiations are enabled, etc, etc.
>
> I have some experience with Nagios as far back as the NetSaint days, but 
> haven't been able to play with it for a few years, and now have the 
> opportunity again.  It looks like it's progressed nicely!
>
> Now, if I could get my may email notifications going, I could dig back 
> in and try to figure out the best way to build configuration files and 
> all of that good stuff!
>
> Thanks!
> Sam
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null
>
>   

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list