nagios邮件发送配置-sendEmail

1.安装sendMail

# cd /u01/software/nagios
# wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
#tar -zxvf sendEmail-v1.56.tar.gz && cd sendEmail-v1.56
#cp sendEmail /usr/local/bin
#chmod 0755 /usr/local/bin/sendEmail

2. 发送邮件测试

# sendEmail -h                (查看sendMail帮助)
# sendEmail -f [email protected] -t [email protected] -s smtp.163.com -xu test -xp password  -u "nagios测试" -m "nagios test 测试"
或者将一个文件的内容作为附件发出, 并且是gb2312或utf8编码的html格式文件(可以显示中文):
#sendEmail -f [email protected] -t [email protected] -s smtp.163.com -xu test -xp password  -u "nagios测试" -m "nagios test 测试" -a /var/log/messages -o message-content-type=html -o message-charset=gb2312

部分参数如下:

-f  表示from,发件人地址

-t  表示to,收件人地址

-s  mail服务器域名

-u  主题

-xu 用户名(@之前的)

-xp 用户密码

-m 纯文本信息

-o message-file=/root/..      发送文件中的内容

-a 发送附件                 -m,-o,-a可以同时使用)

例如:

sendEmail -f [email protected] -t [email protected] -s smtp.163.com -xu test -xp password  -u "nagios测试" -m "nagios test 测试"




这个跟我们的nagios发件方式类似,下面我们来改nagios的发件方式:

command.cfg配置修改email发送方式

define command{
     command_name notify-by-email
     command_line /usr/bin/printf "%b" "***** Nagios 2.9 *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s [email protected]  -u "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -xu [email protected] -xp 123456 
}

把两段关于email的发送方式的定义都改了吧,最后重启一下nagios!



猜你喜欢

转载自blog.csdn.net/heli_lieren/article/details/19904543
今日推荐