Add mail templates, plus initial status alert delay for probes

i.e. let the temp get "proper bad" (for some minutes) before alerting
This commit is contained in:
Lance Edgar 2016-12-10 12:40:50 -06:00
parent d87ea6c22d
commit 646f09a413
6 changed files with 95 additions and 1 deletions

View file

@ -113,7 +113,18 @@ class TempmonServerDaemon(Daemon):
probe.status_changed = self.now
probe.status_alert_sent = None
# no email if status is good
# send email when things go back to normal, after being bad
if status == self.enum.TEMPMON_PROBE_STATUS_GOOD_TEMP:
send_email(self.config, 'tempmon_good_temp', {
'probe': probe,
'status': self.enum.TEMPMON_PROBE_STATUS[status],
'reading': reading,
'taken': localtime(self.config, reading.taken, from_utc=True) if reading else None,
'now': localtime(self.config),
})
probe.status_alert_sent = self.now
# no (more) email if status is good
if status == self.enum.TEMPMON_PROBE_STATUS_GOOD_TEMP:
return
@ -123,6 +134,11 @@ class TempmonServerDaemon(Daemon):
if (self.now - probe.status_alert_sent) <= timeout:
return
# delay even the first email, until configured threshold is reached
timeout = datetime.timedelta(minutes=probe.therm_status_timeout)
if (self.now - probe.status_changed) <= timeout:
return
msgtypes = {
self.enum.TEMPMON_PROBE_STATUS_LOW_TEMP : 'tempmon_low_temp',
self.enum.TEMPMON_PROBE_STATUS_HIGH_TEMP : 'tempmon_high_temp',