Notifications not working [was: Re: '$' symbol being appended to command_line?]

Alexis Hazell alexis.hazell at gmail.com
Thu Jan 8 01:27:09 CET 2009


On 07:28:01 Wed 07-Jan-09, Marc Powell wrote:
> What's the real command_line that you're using for notifications?

For email:

    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

For XMPP:

    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/freetalk -s /var/log/nagios/notify.scm


> You could also redirect STDOUT/STDERR to a file to see if anything is  
> being reported there by adding '>/tmp/output.txt 2>&1' to the end of  
> the command_line.

Doing this showed that you are correct about it being a permissions
issue: nagios is running as user 'nagios' and group 'nagios', but
the /bin/mail and /usr/bin/freetalk commands are being run in an
environment where it seems that HOME=/root/ - the commands attempt to
access /root/.esmtprc and /root/.freetalk/, respectively, rather than
attempting to access /var/log/nagios/.esmtprc and
/var/log/nagios/.freetalk/ (where /var/log/nagios is HOME for user
nagios).

Obvious kludges are:

* copy the respective dot files to /root/ and either chmod them o+r
or chown them root.nagios;

* modify the command_line to use sudo to ensure /bin/mail and
/usr/bin/freetalk are run as user 'nagios'.

But surely there's a better alternative? What am i missing?


Alexis.

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
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