您好,登录后才能下订单哦!
本篇文章为大家展示了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 test@126.com -t test@qq.com -s smtp.126.com -xu test@126.com -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 test@test.com ; <<***** 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 test@126.com -t $CONTACTEMAIL$ -s smtp.126.com -u "**$HOSTALIAS$ is $HOSTSTATE$**"-xu test@126.com -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 test@126.com -t $CONTACTEMAIL$ -s smtp.126.com -u "**$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$**" -xu test@126.com -xp password -o message-charset=utf8
}
5、重启服务
上述内容就是nagios中怎么设置邮件报警,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。