nagios使用邮件来告警通知是很常见的一种方式。
1. 使用sendEmail来发送邮件文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-mail-notify/
sendEmail工具非常好用。具体内容参见:文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-mail-notify/
《如何使用sendEmail发送邮件》文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-mail-notify/
2. 创建一个联系人文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-mail-notify/
# vim /usr/local/nagios/etc/objects/contacts.cfg define contact{ contact_name mobei alias mobei service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c host_notification_options d,u service_notification_commands notify-service-by-email host_notification_commands notify-host-by-email email 【You email address】 }
3. 创建一个组文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-mail-notify/
define contactgroup{ contactgroup_name ops alias ops members mobei }
4. 修改发送邮件命令文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-mail-notify/
# vim /usr/local/nagios/etc/objects/commands.cfg # 'notify-host-by-email' command definition define command{ command_name notify-host-by-email command_line /usr/local/bin/sendEmail -l /tmp/sendEmail.log -f jiank@126.com -t $CONTACTEMAIL$ -s smtp.126.com -u "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" -xu jiank@126.com -xp jiankong -m "Service: $SERVICEDESC$\\nHost: $HOSTALIAS$\\nAddress: $HOSTADDRESS$ State: $SERVICESTATE$\\nDate/Time: $SHORTDATETIME$\\nInfo:$SERVICEOUTPUT$" } # 'notify-service-by-email' command definition define command{ command_name notify-service-by-email command_line /usr/local/bin/sendEmail -l /tmp/sendEmail.log -f jiank@126.com -t $CONTACTEMAIL$ -s smtp.126.com -u "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" -xu jiank@126.com -xp jiankong -m "Service: $SERVICEDESC$\\nHost: $HOSTALIAS$\\nAddress: $HOSTADDRESS$ State: $SERVICESTATE$\\nDate/Time: $SHORTDATETIME$\\nInfo:$SERVICEOUTPUT$" }
5. 指定监控项目。如:文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-mail-notify/
define service { use generic-service hostgroup_name Mongo Servers service_description Mongo Mapped Memory Usage check_command check_mongodb!10.0.0.160!12345!'ttlsa'!'www.ttlsa.com'!memory_mapped!20!28 contact_groups ops }文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-mail-notify/文章源自运维生存时间-https://www.ttlsa.com/nagios/nagios-mail-notify/
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
来自外部的引用