disabled X X X X
dispatch - - X X
email-alert from X X X X
+email-alert level X X X X
email-alert mailers X X X X
email-alert myhostname X X X X
email-alert to X X X X
Also requires "email-alert mailers" and "email-alert to" to be set
and if so sending email alerts is enabled for the proxy.
- See also : "email-alert mailers", "email-alert myhostname", "email-alert to",
+ See also : "email-alert level", "email-alert mailers",
+ "email-alert myhostname", "email-alert to", section 3.6 about mailers.
+
+
+email-alert level <level>
+ Declare the maximum log level of messages for which email alerts will be
+ sent. This acts as a filter on the sending of email alerts.
+ May be used in sections: defaults | frontend | listen | backend
+ yes | yes | yes | yes
+
+ Arguments :
+
+ <level> One of the 8 syslog levels:
+ emerg alert crit err warning notice info debug
+ The above syslog levels are ordered from lowest to highest.
+
+ By default level is alert
+
+ Also requires "email-alert from", "email-alert mailers" and
+ "email-alert to" to be set and if so sending email alerts is enabled
+ for the proxy.
+
+ See also : "email-alert from", "email-alert mailers",
+ "email-alert myhostname", "email-alert to",
section 3.6 about mailers.
Also requires "email-alert from" and "email-alert to" to be set
and if so sending email alerts is enabled for the proxy.
- See also : "email-alert from", "email-alert myhostname", "email-alert to",
- section 3.6 about mailers.
+ See also : "email-alert from", "email-alert level", "email-alert myhostname",
+ "email-alert to", section 3.6 about mailers.
email-alert myhostname <hostname>
"email-alert to" to be set and if so sending email alerts is enabled
for the proxy.
- See also : "email-alert from", "email-alert mailers", "email-alert to",
- section 3.6 about mailers.
+ See also : "email-alert from", "email-alert level", "email-alert mailers",
+ "email-alert to", section 3.6 about mailers.
email-alert to <emailaddr>
Also requires "email-alert mailers" and "email-alert to" to be set
and if so sending email alerts is enabled for the proxy.
- See also : "email-alert from", "email-alert mailers",
+ See also : "email-alert from", "email-alert level", "email-alert mailers",
"email-alert myhostname", section 3.6 about mailers.
const char *init_check(struct check *check, int type);
void free_check(struct check *check);
-void send_email_alert(struct server *s, const char *format, ...)
- __attribute__ ((format(printf, 2, 3)));
+void send_email_alert(struct server *s, int priority, const char *format, ...)
+ __attribute__ ((format(printf, 3, 4)));
#endif /* _PROTO_CHECKS_H */
/*
char *from; /* Address to send email alerts from */
char *to; /* Address(es) to send email alerts to */
char *myhostname; /* Identity to use in HELO command sent to mailer */
+ int level; /* Maximum syslog level of messages to send
+ * email alerts for */
+ int set; /* True if email_alert settings are present */
struct email_alertq *queues; /* per-mailer alerts queues */
} email_alert;
};
defproxy.defsrv.onerror = DEF_HANA_ONERR;
defproxy.defsrv.consecutive_errors_limit = DEF_HANA_ERRLIMIT;
defproxy.defsrv.uweight = defproxy.defsrv.iweight = 1;
+
+ defproxy.email_alert.level = LOG_ALERT;
}
curproxy->email_alert.to = strdup(defproxy.email_alert.to);
if (defproxy.email_alert.myhostname)
curproxy->email_alert.myhostname = strdup(defproxy.email_alert.myhostname);
+ curproxy->email_alert.level = defproxy.email_alert.level;
goto out;
}
free(curproxy->email_alert.myhostname);
curproxy->email_alert.myhostname = strdup(args[2]);
}
+ else if (!strcmp(args[1], "level")) {
+ curproxy->email_alert.level = get_log_level(args[2]);
+ if (curproxy->email_alert.level < 0) {
+ Alert("parsing [%s:%d] : unknown log level '%s' after '%s'\n",
+ file, linenum, args[1], args[2]);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
+ }
+ }
else if (!strcmp(args[1], "to")) {
if (*(args[1]) == 0) {
Alert("parsing [%s:%d] : missing argument after '%s'.\n",
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
+ /* Indicate that the email_alert is at least partially configured */
+ curproxy->email_alert.set = 1;
}/* end else if (!strcmp(args[0], "email-alert")) */
else if (!strcmp(args[0], "external-check")) {
if (*(args[1]) == 0) {
}
}
- if ((curproxy->email_alert.mailers.name || curproxy->email_alert.from ||
- curproxy->email_alert.myhostname || curproxy->email_alert.to)) {
+ if (curproxy->email_alert.set) {
if (!(curproxy->email_alert.mailers.name && curproxy->email_alert.from && curproxy->email_alert.to)) {
Warning("config : 'email-alert' will be ignored for %s '%s' (the presence any of "
- "'email-alert from', 'email-alert mailer', 'email-alert hostname' or 'email-alert to' "
+ "'email-alert from', 'email-alert level' 'email-alert mailer', "
+ "'email-alert hostname', or 'email-alert to' "
"requrires each of 'email-alert from', 'email-alert mailer' and 'email-alert' "
"to be present).\n",
proxy_type_str(curproxy), curproxy->id);
Warning("%s.\n", trash.str);
send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
- send_email_alert(s, "%s", trash.str);
+ send_email_alert(s, LOG_NOTICE, "%s", trash.str);
}
}
/*
* Send email alert if configured.
*/
-void send_email_alert(struct server *s, const char *format, ...)
+void send_email_alert(struct server *s, int level, const char *format, ...)
{
va_list argp;
char buf[1024];
int len;
struct proxy *p = s->proxy;
- if (!p->email_alert.mailers.m || format == NULL || !init_email_alert_checks(s))
+ if (!p->email_alert.mailers.m || level > p->email_alert.level ||
+ format == NULL || !init_email_alert_checks(s))
return;
va_start(argp, format);
struct server *srv;
int prev_srv_count = s->proxy->srv_bck + s->proxy->srv_act;
int srv_was_stopping = (s->state == SRV_ST_STOPPING);
+ int log_level;
int xferred;
if ((s->admin & SRV_ADMF_MAINT) || s->state == SRV_ST_STOPPED)
"%sServer %s/%s is DOWN", s->flags & SRV_F_BACKUP ? "Backup " : "",
s->proxy->id, s->id);
- send_email_alert(s, "%s", trash.str);
srv_append_status(&trash, s, reason, xferred, 0);
Warning("%s.\n", trash.str);
/* we don't send an alert if the server was previously paused */
- send_log(s->proxy, srv_was_stopping ? LOG_NOTICE : LOG_ALERT, "%s.\n", trash.str);
+ log_level = srv_was_stopping ? LOG_NOTICE : LOG_ALERT;
+ send_log(s->proxy, log_level, "%s.\n", trash.str);
+ send_email_alert(s, log_level, "%s", trash.str);
if (prev_srv_count && s->proxy->srv_bck == 0 && s->proxy->srv_act == 0)
set_backend_down(s->proxy);