MEDIUM: Allow suppression of email alerts by log level
This patch adds a new option which allows configuration of the maximum
log level of messages for which email alerts will be sent.
The default is alert which is more restrictive than
the current code which sends email alerts for all priorities.
That behaviour may be configured using the new configuration
option to set the maximum level to notice or greater.
email-alert level notice
Signed-off-by: Simon Horman <horms@verge.net.au>
diff --git a/src/checks.c b/src/checks.c
index ea167de..184301c 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -317,7 +317,7 @@
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);
}
}
@@ -3113,14 +3113,15 @@
/*
* 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);