Re: [Nagios-users] Notifications not working [was: Re: '$' symbol being appended to command_line?]
On 11:27:09 Thu 08-Jan-09, Alexis Hazell wrote: > 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? Okay, for future reference for anyone else who might face the same problem, i couldn't get either of the above kludges to work. Instead, what worked was setting the HOME var: command_lineecho 'Nagios notification --- Type: $NOTIFICATIONTYPE$, Service: $SERVICEDESC$, Host: $HOSTALIAS$, Address: $HOSTADDRESS$, State: $SERVICESTATE$, Date/Time: $LONGDATETIME$, Additional Info: $SERVICEOUTPUT$' | HOME=/var/log/nagios /usr/bin/freetalk -s /var/log/nagios/notify.scm where the contents of /var/log/nagios/notify.scm are: (use-modules (ice-9 rdelim)) (define msg (read-line)) (ft-set-jid! "[sender-JID]") (ft-set-server! "talk.google.com") (ft-set-password! "[sender-password]") (ft-set-sslconn! #t) (ft-set-port! 5223) (if (ft-login-blocking) (begin (ft-send-message "[recipient-JID]" msg) (ft-disconnect)) (display "Could not connect\n")) 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@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
Re: [Nagios-users] Notifications not working [was: Re: '$' symbol being appended to command_line?]
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@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
Re: [Nagios-users] Notifications not working [was: Re: '$' symbol being appended to command_line?]
On Jan 7, 2009, at 4:48 AM, Alexis Hazell wrote: > On 22:56:13 Tue 06-Jan-09, Marc Powell wrote: >> Does your mail log on the nagios host show the message >> being received and then sent further on? > > i created a wrapper shell script around esmtp to allow me to call > it with the -X option, which allows one to log all mail traffic to > a file. Running the contents of command_line manually whilst su'd to > user 'nagios' works, with the log file containing the expected traffic > info. But when command_line is called by nagios itself as part of > the notification process, the log file is empty (and despite the '-v' > [i.e. verbose] option being used in the wrapper script). > Any suggestions as to what's going on here would be very much > appreciated! What's the real command_line that you're using for notifications? It sounds to me like a permissions or path issue. Either nagios isn't allowed to execute the program or can't find it. Ensure that permissions are correct on the program and directories above and that you're using /fully/qualified/paths everywhere. 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. -- Marc -- 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@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
[Nagios-users] Notifications not working [was: Re: '$' symbol being appended to command_line?]
On 22:56:13 Tue 06-Jan-09, Marc Powell wrote: > Does your mail log on the nagios host show the message > being received and then sent further on? i created a wrapper shell script around esmtp to allow me to call it with the -X option, which allows one to log all mail traffic to a file. Running the contents of command_line manually whilst su'd to user 'nagios' works, with the log file containing the expected traffic info. But when command_line is called by nagios itself as part of the notification process, the log file is empty (and despite the '-v' [i.e. verbose] option being used in the wrapper script). i then moved on to trying to get notifications via IM - specifically XMPP - using freetalk. This results in the same problem: the contents of command_line work fine when run manually whilst su'd to nagios, but don't when run as part of the notification process. And again, i can confirm that command_line is being called, because: 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$" | cat > /var/log/nagios/output.txt results the notification process creating output.txt at the desired location, containing the correct information. Any suggestions as to what's going on here would be very much appreciated! 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@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