Don't let server mark client as offline until readings fail 3 times in a row
previously we were only letting this fail once, if that
This commit is contained in:
parent
ab38143039
commit
018a9dcb08
|
@ -80,10 +80,26 @@ class TempmonServerDaemon(Daemon):
|
||||||
online = True
|
online = True
|
||||||
for probe in client.enabled_probes():
|
for probe in client.enabled_probes():
|
||||||
online = online and bool(self.check_readings_for_probe(session, probe, cutoff))
|
online = online and bool(self.check_readings_for_probe(session, probe, cutoff))
|
||||||
if not online and client.online:
|
|
||||||
|
# if client was previously marked online, but we have no "new"
|
||||||
|
# readings, then let's look closer to see if it's been long enough to
|
||||||
|
# mark it offline
|
||||||
|
if client.online and not online:
|
||||||
|
|
||||||
|
# we consider client offline if it has failed to take readings for
|
||||||
|
# 3 times in a row. allow a one minute buffer for good measure.
|
||||||
|
cutoff = self.now - datetime.timedelta(seconds=(delay * 3) + 60)
|
||||||
|
reading = session.query(tempmon.Reading)\
|
||||||
|
.filter(tempmon.Reading.client == client)\
|
||||||
|
.filter(tempmon.Reading.taken >= cutoff)\
|
||||||
|
.first()
|
||||||
|
if not reading:
|
||||||
log.info("marking client as OFFLINE: {}".format(client))
|
log.info("marking client as OFFLINE: {}".format(client))
|
||||||
client.online = False
|
client.online = False
|
||||||
send_email(self.config, 'tempmon_client_offline', {"client":client, "now":localtime(self.config,self.now,from_utc=True)})
|
send_email(self.config, 'tempmon_client_offline', {
|
||||||
|
'client': client,
|
||||||
|
'now': localtime(self.config, self.now, from_utc=True),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def check_readings_for_probe(self, session, probe, cutoff):
|
def check_readings_for_probe(self, session, probe, cutoff):
|
||||||
|
|
Loading…
Reference in a new issue