我想问一下,是否有可能通过postfix从nagios发送电子邮件?
1,我已经设置了nagios来检查一些服务,我也安装了postfix。
2,我有有效的电子邮件帐户,即:patrick@mydomain.com
3,只需发送此帐户的电子邮件
谢谢!
帕特里克
答案 0 :(得分:1)
以下是Ubuntu的一种可能解决方案。
确保已安装bsd-mailx和postfix:
sudo apt-get install postfix bsd-mailx
Postfix应配置为卫星系统,这意味着/etc/postfix/main.cf应包含:
relayhost = your_smtp_relay_address
然后您需要通过添加“from”地址来更改Nagios通知命令:
# '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" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ -- $USER5$
}
# '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" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
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" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ -- $USER5$
}
其中$ USER5 $在/etc/nagios3/resource.cfg中定义并包含如下内容:
$USER5$="-f nagios.notifications@company.lan"
答案 1 :(得分:0)
是的,有可能。根据您使用的Nagios版本/分支,配置会有所不同。
我们使用Icinga(nagios fork),我可以将您链接到文档中的确切页面。我不熟悉nagios文档,但这些内容应该有:http://community.spiceworks.com/topic/144821-nagios-e-mail-alerts-with-postfix。