1、安装相关组建
yum install mailx sendmail*
chkconfig sendmail on
service sendmail start
2、测试邮件
echo "Hello World" | mail abc@abc.com
3、设置发件人
[root@localhost]#vi /etc/mail.rc
set from=skykws@163.com smtp=smtp.163.com set smtp-auth-user=skykws smtp-auth-password=000000 smtp-auth=login
4、编辑command.cfg
# 'notify-host-by-email' command definition
define command{
command_namenotify-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 -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_namenotify-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 -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
4、重启nagios
service nagios restart
5、后记
关于报警发送间隔等等设置不做详细介绍
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。