change overdue state to unknown anfetr 7 days
This commit is contained in:
@@ -55,6 +55,7 @@ verbose = False
|
||||
|
||||
INTERVAL = 10
|
||||
GRACE = 2
|
||||
DROPOVERDUE = 7*24*3600
|
||||
|
||||
os.environ['TZ'] = 'EST5EDT'
|
||||
|
||||
@@ -305,6 +306,8 @@ def checkoverdue():
|
||||
if conn.state == Connection.up and (now - conn.lastbeat) > timeout:
|
||||
conn.newstate(Connection.overdue, now, grace)
|
||||
pmsg.append(conn.afam)
|
||||
if conn.state == Connection.overdue and (now - conn.lastbeat) > DROPOVERDUE:
|
||||
conn.newstate(Connection.unknown, conn.lastbeat)
|
||||
if pmsg != []:
|
||||
if h in watchhosts:
|
||||
email("overdue", "%s overdue" % " and ".join(pmsg))
|
||||
|
||||
+10
-1
@@ -51,6 +51,8 @@ class Connection:
|
||||
d['addr'] = self.addr
|
||||
if self.rtts[-1]:
|
||||
d['rtt'] = "%0.1f" % self.rtts[-1]
|
||||
elif self.state == Connection.unknown:
|
||||
d['rtt'] = ""
|
||||
else:
|
||||
d['rtt'] = "?"
|
||||
d['lastbeat'] = self.lastbeat
|
||||
@@ -60,11 +62,16 @@ class Connection:
|
||||
d['state'] = self.state
|
||||
if self.state == Connection.up:
|
||||
d['rttstate'] = d['rtt']
|
||||
elif self.state == Connection.overdue:
|
||||
d['rttstate'] = ''
|
||||
else:
|
||||
d['rttstate'] = d['state']
|
||||
d['statetime'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(self.statetime))
|
||||
delta = now - self.statetime
|
||||
if delta > 86400:
|
||||
|
||||
if self.state == Connection.unknown:
|
||||
d['deltastatetime'] = ''
|
||||
elif delta > 86400:
|
||||
# d['deltastatetime'] = time.strftime("%d %H:%M:%S", time.gmtime(delta))
|
||||
d['deltastatetime'] = "%0.1f days" % (delta / 86400.)
|
||||
elif delta > 3600:
|
||||
@@ -257,6 +264,8 @@ class Host:
|
||||
state += " %5.1f" % (self.connections[x].rtts[-1])
|
||||
except:
|
||||
state += " %5s" % (self.connections[x].rtts[-1])
|
||||
elif self.state in ["unknown", "UNKNOWN"]:
|
||||
state = ""
|
||||
else:
|
||||
state = "%s" % self.state
|
||||
return state
|
||||
|
||||
Reference in New Issue
Block a user