原创作品,允许转载,转载时请务必以超链接形式标明文章
原始出处 、作者信息和本声明。否则将追究法律责任。
http://beanxyz.blog.51cto.com/5570417/1630221
1
|
vim /etc/postfix/sasl_passwd
|
1
|
[smtp.office365.com]:587 nagios@xxx.com:password
|
1
|
postmap hash:/etc/postfix/sasl_passwd
|
1
2
3
4
5
|
relayhost = [smtp.office365.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_security_level = may
smtp_sasl_security_options = noanonymous
|
1
|
inet_protocols=ipv4
|
1
|
mydestination=
|
1
|
echo 'test smtp' | mail -r nagios@xxx.com -s 'test email' abc@test.com
|
1
2
3
4
5
6
7
8
|
[root@sydnagios postfix]# tail /var/log/maillog
Apr 9 09:22:53 sydnagios postfix/pickup[20595]: 8215039D9A9: uid=1001 from=<nagios@aus.ddb.com>
Apr 9 09:22:53 sydnagios postfix/cleanup[44919]: 8215039D9A9: message-id=<5525b84d.6PVA0r3rChf2lRe/%nagios@aus.ddb.com>
Apr 9 09:22:53 sydnagios postfix/qmgr[63629]: 8215039D9A9: from=<nagios@aus.ddb.com>, size=748, nrcpt=1 (queue active)
Apr 9 09:23:03 sydnagios postfix/smtp[44921]: 8215039D9A9: to=<italerts@aus.ddb.com>, relay=smtp.office365.com[132.245.164.34]:587, delay=9.6, delays=0.01/0/9/0.59, dsn=2.6.0, status=sent (250 2.6.0 <5525b84d.6PVA0r3rChf2lRe/%nagios@aus.ddb.com> [InternalId=20280835574078, Hostname=SIXPR04MB0462.apcprd04.prod.outlook.com] Queued mail for delivery)
Apr 9 09:23:03 sydnagios postfix/qmgr[63629]: 8215039D9A9: removed
Apr 9 09:24:42 sydnagios postfix/pickup[20595]: B3F7539D9A9: uid=1001 from=<nagios@aus.ddb.com>
Apr 9 09:24:42 sydnagios postfix/cleanup[45911]: B3F7539D9A9: message-id=<5525b
|
1
2
3
4
5
6
7
8
9
10
|
# '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$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -r nagios@XXX.com -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# '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: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -r nagios@XXX.com -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
|
1
|
systemctl restart Nagios
|