Nagios email alert configuration

时间:2018-03-25 21:04:15

标签: email ubuntu-16.04 nagios postfix

I am configuring Nagios to send email alerts through postfix configured to an SMTP Relay Server, I have configured my commands.cfg and contacts.cfg to contain the required settings. However, whenever the email goes out, it is not picking up the configurations I have in my contacts.cfg and always takes a default email id:

Mar 26 02:20:05 dash postfix/pickup[24908]: 395DBBE0DC3: uid=1002 from=<oem>
Mar 26 02:20:05 dash postfix/cleanup[25635]: 395DBBE0DC3: message-id=<20180325205005.395DBBE0DC3@dash.in>
Mar 26 02:20:05 dash postfix/qmgr[17430]: 395DBBE0DC3: from=<oem@dash.in>, size=595, nrcpt=1 (queue active)
Mar 26 02:20:10 dash postfix/smtp[25637]: 395DBBE0DC3: to=<oem@dash.in>, orig_to=<oem>, relay=relay.smtp.dash.in:587, delay=5.6, delays=0.01/0.01/3.8/1.7, dsn=2.0.0, status=sent (250 Ok 010101625eecf59b-243d9f21-ae1c-4272-9213-55e11d7d5e25-000000)
Mar 26 02:20:11 dash postfix/qmgr[17430]: 395DBBE0DC3: removed

I have not configured the oem user anywhere in postfix or nagios, however there is an oem user on my system. I'm missing something basic I feel, if anyone has any idea do let me know. Cheers!

1 个答案:

答案 0 :(得分:0)

使用grep找出它的配置位置:

$ sudo grep -s -R "oem@dash.in" /etc/*
$ sudo grep -s -R "oem@dash.in" /usr/local/nagios/*

$ cat /usr/local/nagios/etc/nagios.cfg | grep @
admin_email=myaccount@gmail.com
admin_pager=myaccount@gmail.com

$ cat /usr/local/nagios/etc/objects/contacts.cfg | grep @
    email                   nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
    email                   myaccount@gmail.com;

通过以下方式测试您的配置:

$ echo "Test Email message body" | mail -r account_accepted_by_relay@mydomainname.onmicrosoft.com -s "Email test subject" myaccount@gmail.com

在使用该测试命令之前,我已经安装了mailutils:

$ sudo apt install mailutils

我正在使用sendgrid,所以我的 main.cf 配置包括:

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = localhost.localdomain

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, localhost
relayhost = [smtp.sendgrid.net]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_tls_security_options = noanonymous

您可以查看here以获得更详细的说明。