I have set up a haproxy configuration with a backend with two servers looking like that:
...
default
option log-health-checks
...
mailers mta
mailer smtp1 127.0.0.1:25
...
backend s_api
balance roundrobin
option httpchk GET /sites?site=q&limit=1
http-check expect rstatus (2|3)[0-9][0-9]
server s1_a 1.2.3.4:3600 check inter 5s fall 4 rise 1
server s2_b 1.2.3.5:3600 check backup
timeout queue 60s
timeout server 60s
timeout connect 60s
email-alert mailers mta
email-alert level notice
email-alert from haproxy@example.com
email-alert to ops@example.com
I now get noticed via email when a server gets down and up again. What I would like to archive is to start a local bash script when a server is going up and another one when the server is going down.
How could that be done?