nagios邮件报警设置
1、下载 sendEmail
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
2、配置 sendEmail
tar zxvf sendEmail-v1.56.tar.gz
cd sendEmail-v1.56
cp sendEmail /usr/local/bin
chmod 777 /usr/local/bin/sendEmail
发送测试邮件
/usr/local/bin/sendEmail -f [email protected] -t [email protected] -s smtp.126.com -xu [email protected] -xp password -u "nagios" -m "tets"
解释:
-f表示发送者的邮箱
-t表示接收者的邮箱
-s表示SMTP服务器的域名或者ip
-u表示邮件的主题
-xu表示SMTP验证的用户名
-xp表示SMTP验证的密码
-m表示邮件的内容
3、配置contacts.cfg
vi /usr/local/nagios/etc/objects/contacts.cfg 输入接收报警邮箱地址
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
4、配置commands.cfg
vi /usr/local/nagios/etc/objects/commands.cfg
注解# ‘notify-host-by-email‘ command definition 与# ‘notify-service-by-email‘ command definition下所有的设置
重新输入以下内容
# ‘notify-host-by-email‘ command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s smtp.126.com -u "**$HOSTALIAS$ is $HOSTSTATE$**"-xu [email protected] -xp password -o message-charset=utf8
}
# ‘notify-service-by-email‘ command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\nNotification Type: $NOTIFICATIONTYPE$\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n$SERVICEOUTPUT$\n" | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s smtp.126.com -u "**$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$**" -xu [email protected] -xp password -o message-charset=utf8
}
5、重启服务
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。