MEDIUM: Send email alerts when servers are marked as UP or enter the drain state

This is similar to the way email alerts are sent when servers are marked as
DOWN.

Like the log messages corresponding to these state changes the messages
have log level notice. Thus they are suppressed by the default email-alert
level of 'alert'. To allow these messages the email-alert level should
be set to 'notice', 'info' or 'debug'. e.g:

email-alert level notice

"email-alert mailers" and "email-alert to" settings are also required in
order for any email alerts to be sent.

A follow-up patch will document the above.

Signed-off-by: Simon Horman <horms@verge.net.au>
This commit is contained in:
Simon Horman 2015-04-30 13:10:34 +09:00 committed by Willy Tarreau
parent 7ea9be012d
commit 4cd477f372

View File

@ -332,6 +332,7 @@ void srv_set_running(struct server *s, const char *reason)
srv_append_status(&trash, s, reason, xferred, 0); srv_append_status(&trash, s, reason, xferred, 0);
Warning("%s.\n", trash.str); Warning("%s.\n", trash.str);
send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str); send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
send_email_alert(s, LOG_NOTICE, "%s", trash.str);
for (srv = s->trackers; srv; srv = srv->tracknext) for (srv = s->trackers; srv; srv = srv->tracknext)
srv_set_running(srv, NULL); srv_set_running(srv, NULL);
@ -484,6 +485,7 @@ void srv_set_admin_flag(struct server *s, enum srv_admin mode)
Warning("%s.\n", trash.str); Warning("%s.\n", trash.str);
send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str); send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
send_email_alert(s, LOG_NOTICE, "%s", trash.str);
if (prev_srv_count && s->proxy->srv_bck == 0 && s->proxy->srv_act == 0) if (prev_srv_count && s->proxy->srv_bck == 0 && s->proxy->srv_act == 0)
set_backend_down(s->proxy); set_backend_down(s->proxy);