Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
tgriep
Madmin
Posts: 9190 Joined: Thu Oct 30, 2014 9:02 am
Post
by tgriep » Wed Jul 08, 2015 3:32 pm
You would edit the 2 commands shown below and add -r
[email protected] to the end of the command_line.
Remember to replace
[email protected] with a real email address.
Code: Select all
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAd
dress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE
$ **" $CONTACTEMAIL$ -r [email protected]
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALI
AS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIF
ICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ -r [email protected]
}
Be sure to check out our
Knowledgebase for helpful articles and solutions!
Jessuzz94
Posts: 162 Joined: Thu Jun 04, 2015 12:08 pm
Post
by Jessuzz94 » Wed Jul 08, 2015 4:23 pm
It doesnt work u.u, in the mail.log dont show me anything information, if the notifications cant sends, or yes, nothing:/, i think that is bad configuration that i do to postfix to run the notifications
tgriep
Madmin
Posts: 9190 Joined: Thu Oct 30, 2014 9:02 am
Post
by tgriep » Thu Jul 09, 2015 9:12 am
I will need to get your configuration files to debug this issue. I will need the nagios.cfg file. I will need the contact, host and service configurations for one of the systems you are checking.
You can either post them here or PM the files to me.
Be sure to check out our
Knowledgebase for helpful articles and solutions!
Jessuzz94
Posts: 162 Joined: Thu Jun 04, 2015 12:08 pm
Post
by Jessuzz94 » Thu Jul 09, 2015 1:55 pm
There is something:
Attachments
host and service configuration server.png (11.62 KiB) Viewed 3100 times
contacts.cfg in nagios postfix3.png (9.08 KiB) Viewed 3100 times
main.cf of postfix postfix.png (4.76 KiB) Viewed 3100 times
jdalrymple
Skynet Drone
Posts: 2620 Joined: Wed Feb 11, 2015 1:56 pm
Post
by jdalrymple » Thu Jul 09, 2015 4:10 pm
Jessuzz94 wrote: The command "tail -f /var/log/maillog" doesnt work, says no such file in directory, i use ubuntu server i think is that.
The invalid address shows me this in the mail.log, i can send mails to everybody, but the notifications of nagios doesnt work, i configured contacts , commands , host and services to enable notifications and short intervals test if works.
Code: Select all
Jul 7 14:50:18 ubuntu postfix/pickup[1073]: 4793315FCB2: uid=1001 from=<nagios>
Jul 7 14:50:18 ubuntu postfix/cleanup[2155]: 4793315FCB2: message-id=<20150707215018.4793315FCB2@ubuntu>
Jul 7 14:50:18 ubuntu postfix/qmgr[1074]: 4793315FCB2: from=<nagios@ubuntu>, size=422, nrcpt=1 (queue active)
Jul 7 14:50:18 ubuntu postfix/smtp[2157]: warning: database /etc/postfix/sasl_passwd.db is older than source file /etc/postfix/sasl_passwd
Jul 7 14:50:21 ubuntu postfix/smtp[2157]: 4793315FCB2: to=<[email protected] >, relay=smtp.gmail.com[173.194.64.109]:587, delay=2.8, delays=0.03/0.02/1.7/1, dsn=2$
Jul 7 14:50:21 ubuntu postfix/qmgr[1074]: 4793315FCB2: removed
What was it you did that worked? I'm still thinking this is likely a mail server setup issue - not a Nagios issue.
Jessuzz94
Posts: 162 Joined: Thu Jun 04, 2015 12:08 pm
Post
by Jessuzz94 » Fri Jul 10, 2015 11:23 am
i tought that was problem of both
jdalrymple
Skynet Drone
Posts: 2620 Joined: Wed Feb 11, 2015 1:56 pm
Post
by jdalrymple » Fri Jul 10, 2015 11:41 am
jdalrymple wrote: What was it you did that worked?
Please answer that question. The aforementioned excerpt of maillog indicates a successfully sent E-mail. How did that get sent?
Jessuzz94
Posts: 162 Joined: Thu Jun 04, 2015 12:08 pm
Post
by Jessuzz94 » Fri Jul 10, 2015 1:15 pm
it sends emails succesfully with the command | mail -s "test"
[email protected] , but doesnt send notifications to the nagios email that i configured.
tgriep
Madmin
Posts: 9190 Joined: Thu Oct 30, 2014 9:02 am
Post
by tgriep » Fri Jul 10, 2015 1:37 pm
Could you check your nagios.cfg file and check to see in notifications are enabled like below?
If it is not, set it to 1 and restart nagios
Be sure to check out our
Knowledgebase for helpful articles and solutions!
jdalrymple
Skynet Drone
Posts: 2620 Joined: Wed Feb 11, 2015 1:56 pm
Post
by jdalrymple » Fri Jul 10, 2015 1:51 pm
We need to see your notification commands, notify-host-by-email and notify-service-by-email.