diff --git a/plugins/mail.py b/plugins/mail.py index b1ca5e8db13cd88d5fb2bc7849e5cf63e71b66c5..1416fef6551d55373659ed843b1fc9ac5cef5618 100644 --- a/plugins/mail.py +++ b/plugins/mail.py @@ -65,6 +65,9 @@ The last received line was: please check if the controller is going haywire. +I will try to fix this issue by reconnecting... + + Regards, Temperature """ @@ -116,10 +119,14 @@ class PluginMail: smtp.quit() async def err_nodata(self, **kwargs): - await self.send_mail(NO_DATA_SUBJECT, NO_DATA_BODY) + await self.send_mail( + NO_DATA_SUBJECT.format(**kwargs), + NO_DATA_BODY.format(**kwargs)) - async def err_no_valid_data(self, **lwargs): - await self.send_mail(NO_VALID_DATA_SUBJECT, NO_VALID_DATA_BODY) + async def err_no_valid_data(self, **kwargs): + await self.send_mail( + NO_VALID_DATA_SUBJECT.format(**kwargs), + NO_VALID_DATA_BODY.format(**kwargs)) async def err_unknown_sensor(self, **kwargs): await self.send_mail( @@ -137,7 +144,7 @@ class PluginMail: SENSOR_MEASUREMENT_MISSED_BODY.format(**kwargs)) - async def temperature_warning(self, source, **kwargs): + async def temperature_warning(self, source, urgent=False, **kwargs): subject = "Temperaturwarnung Serverraum" body = """Hi Guys, @@ -169,4 +176,5 @@ Temperator""" for sensor in self.monitor.sensors.values() ]) await self.send_mail(subject, body.format( - temperatures=temperatures, reason=reason, alltemperatures=alltemperatures)) + temperatures=temperatures, reason=reason, alltemperatures=alltemperatures), + urgent=urgent) diff --git a/plugins/warnings.py b/plugins/warnings.py index 02d3530f15e2da203fe99ac5c238e3bc23ca98b3..372a898a34fb4b23736eef071a10f0e39f070c72 100644 --- a/plugins/warnings.py +++ b/plugins/warnings.py @@ -112,7 +112,25 @@ class PluginWarning: print("ceil: min {:05.2f} max {:05.2f} avg {:05.2f} var {:05.2f}".format( ceil_min, ceil_max, ceil_avg, ceil_var)) + # Here comes the warning magic + + # Critical: ceiling temperature > threshold (sane default: 45) + if ceil_max > int(self.warning_conf['ceiling_critical_level']): + await self.monitor.call_plugin("temperature_warning", + source="singlehot", + name="ceiling", + temp=ceil_max, + urgent=True) + + # Warning: ceiling tempareture > threshold (sane default: 40) + if ceil_avg > int(self.warning_conf['ceiling_warning_level']): + await self.monitor.call_plugin("temperature_warning", + source="singlehot", + name="ceiling", + temp=ceil_avg) + + # Warning: temperature difference > threshold (sane default: 17) if ceil_max > int(self.warning_conf['min_ceiling_warning']): if tempdiff > int(self.warning_conf['floor_ceiling_diff']): await self.monitor.call_plugin("temperature_warning", @@ -123,8 +141,3 @@ class PluginWarning: temp2=ceil_avg, tempdiff=tempdiff) - if ceil_avg > int(self.warning_conf['ceiling_warning_level']): - await self.monitor.call_plugin("temperature_warning", - source="singlehot", - name="ceiling", - temp=ceil_avg)