简体   繁体   中英

Nagios email alert configuration

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!

Use grep to find out where it is configured:

$ 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;

Test your configuration by:

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

I've installed mailutils before using that test command:

$ sudo apt install mailutils

I'm using sendgrid, so my main.cf configuration includes:

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

You could look here for more detailed explanation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM