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:
parent
d87ea6c22d
commit
646f09a413
|
@ -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',
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
<b>This is an alert from ${probe}!</b><br>
|
||||
The status of ${probe} is: ${status}.<br>
|
||||
The current temperature is: ${reading.degrees_f}.<br>
|
||||
The temperature should never be this high.
|
||||
Investigate Immediately!<br>
|
||||
</p>
|
||||
<p>
|
||||
Notes: <br>
|
||||
Frozen food that is above 40 degrees needs to be thrown away<br>
|
||||
if it remains at that temperature for two hours or more.<br>
|
||||
</p>
|
||||
<p>
|
||||
Check out <a href="http://www.fsis.usda.gov/wps/portal/fsis/topics/food-safety-education/get-answers/food-safety-fact-sheets/safe-food-handling/freezing-and-food-safety/CT_Index/!ut/p/a1/jZFRT8IwEIB_DY9dbw7J8G1ZYtiUTYJK2Qsp7NYt2dqlrU759RZ8UQJK-9LefV-ud6UFZbSQ_L0R3DZK8vZwLyYbWMDEn8aQ5lP_HpLsdZE_xDGEy1sHrP8AsuBK_8KK4D8_vaLAjZ7Hc0GLntuaNLJSlAm0hEszoDaUVUqVxPAK7Sep-M4SUyNalzjEyDFbc1m2jRQO1oh7d3J6SX6YlMXPm0SW-EFXtPj9KvDdTrJgOZ6lWQD5-BQ4M7Zv4PJcXOOiVdvjH60juQ1C16HGCjVq7027cG1tb-5GMIJhGDyhlGjR26nunFArYyk74fruhe0foxk0T90qNNEXiOIqAA!!/#16">this USDA link</a> for useful information
|
||||
</p>
|
||||
<p>
|
||||
This email will repeat every 15 minutes until the issue<br>
|
||||
has been resolved.
|
||||
</p>
|
||||
<p>
|
||||
</body>
|
||||
</html>
|
10
rattail_tempmon/templates/mail/tempmon_error.html.mako
Normal file
10
rattail_tempmon/templates/mail/tempmon_error.html.mako
Normal file
|
@ -0,0 +1,10 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<html>
|
||||
<body>
|
||||
<p>At ${taken or now}, ${probe} reported that its status was: ${status}.<br>
|
||||
Something went wrong. Please investigate as soon as possible.
|
||||
</p>
|
||||
<p>This email will repeat every 15 minutes until the issue is resolved.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,9 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<html>
|
||||
<body>
|
||||
<p><b>This is a notice from ${probe}.</b><br>
|
||||
Things are back to normal now, status is: ${status}.<br />
|
||||
Current temperature is within expected range, at ${reading.degrees_f}
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
17
rattail_tempmon/templates/mail/tempmon_high_temp.html.mako
Normal file
17
rattail_tempmon/templates/mail/tempmon_high_temp.html.mako
Normal file
|
@ -0,0 +1,17 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<html>
|
||||
<body>
|
||||
<p><b>This is a warning from ${probe}.</b><br>
|
||||
The status of ${probe} is: ${status}.<br>
|
||||
This is because the temperature is ${reading.degrees_f}<br>
|
||||
and has been so for longer than expected.<br>
|
||||
This unit should be looked at as soon<br>
|
||||
as possible to ensure no food goes to waste.
|
||||
</p>
|
||||
<p>
|
||||
Notes:<br>
|
||||
This alert will happen every 15 minutes until<br>
|
||||
the temperature reaches an acceptable level.<br>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
17
rattail_tempmon/templates/mail/tempmon_low_temp.html.mako
Normal file
17
rattail_tempmon/templates/mail/tempmon_low_temp.html.mako
Normal file
|
@ -0,0 +1,17 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<html>
|
||||
<body>
|
||||
<p><b>This is a warning from ${probe}.</b><br>
|
||||
The status of ${probe} is: ${status}.<br>
|
||||
This is because the temperature is ${reading.degrees_f}<br>
|
||||
and has been so for longer than expected.<br>
|
||||
This unit should be looked at as soon<br>
|
||||
as possible to ensure no food goes to waste.
|
||||
</p>
|
||||
<p>
|
||||
Notes:<br>
|
||||
This alert will happen every 15 minutes until<br>
|
||||
the temperature reaches an acceptable level.<br>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue