如何设置haproxy节点异常邮件通知?
- By : Will
- Category : Load balancing

Load balancing
1 前言
一个问题,一篇文章,一出故事。
笔者haproxy上代理的节点越来越多,因此被haproxy代理的服务如果异常,笔者希望haproxy能发出邮件警告。
于是整理当前章节。
2 最佳实践
2.1 环境信息
2.1.1 准备haproxy环境
2.1.2 准备带代理的smtp中继服务器环境
注:smtp.cmdschool.org解析到负载均衡器(简单点理解成发送邮件的smtp地址即可)
2.2 配置状态页面
2.2.1 增加配置
vim /etc/haproxy/haproxy.cfg
加入如下配置,
defaults #... email-alert mailers smtp_servers email-alert from haproxy@cmdschool.org email-alert to admin@cmdschool.org email-alert level info email-alert myhostname [hostname] mailers smtp_servers mailer smtp1 smtp.cmdschool.org:25
配置创建后,建议你使用如下命令测试配置,
haproxy -c -f /etc/haproxy/conf.d
2.2.2 重载服务使配置生效
systemctl reload haproxy
参阅文档
===================
https://www.haproxy.com/documentation/haproxy-configuration-tutorials/alerts-and-monitoring/email-alerts/#see-also
没有评论