-
-
Save haproxytechblog/b89ceb0e9cc3427c8d49dbe54eb7a4cd to your computer and use it in GitHub Desktop.
How to Create Powerful, Customized Lua Mailers in HAProxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
lua-load /path/to/file/mailers.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mailers smtp_servers | |
mailer mailserver1 mailserver1.example.com:25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
lua-load /path/to/file/mailers.lua | |
mailers mymailers | |
mailer smtp1 192.168.0.1:587 | |
mailer smtp2 192.168.0.2:587 | |
backend myback | |
email-alert mailers mymailers | |
email-alert from test1@domain.name | |
email-alert to test2@domain.name | |
# add your own monitored backend server entries below |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- prepare email body | |
c:add(string.format("From: %s\r\n", job.mailconf.smtp_from)) | |
c:add(string.format("To: %s\r\n", job.mailconf.smtp_to)) | |
c:add(string.format("Date: %s\r\n", date)) | |
c:add(string.format("Subject: [HAProxy Alert] %s\r\n", job.msg)) | |
c:add("\r\n") | |
c:add(string.format("%s\r\n", job.msg)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment