cpitalize constants

This commit is contained in:
2022-03-09 08:46:41 -05:00
parent cddf809759
commit 96eb380d58
2 changed files with 13 additions and 13 deletions
+3 -3
View File
@@ -423,12 +423,12 @@ def checkoverdue():
continue
timeout = hbdclass.Host.hosts[h].interval + grace
if conn.state == hbdclass.Connection.up and (now - conn.lastbeat) > timeout:
conn.newstate(hbdclass.Connection.overdue, now, grace)
conn.newstate(hbdclass.Connection.OVERDUE, now, grace)
pmsg.append(conn.afam)
if (
conn.state == hbdclass.Connection.overdue and (now - conn.lastbeat) > DROPOVERDUE
conn.state == hbdclass.Connection.OVERDUE and (now - conn.lastbeat) > DROPOVERDUE
):
conn.newstate(hbdclass.Connection.unknown, conn.lastbeat)
conn.newstate(hbdclass.Connection.UNKNOWN, conn.lastbeat)
if pmsg != []:
if h in watchhosts:
email("overdue", "%s overdue" % " and ".join(pmsg))
+10 -10
View File
@@ -25,10 +25,10 @@ class Connection:
# map of addrs to names
htab = {}
unknown = "unknown"
up = "up"
down = "down"
overdue = "overdue"
UNKNOWN = "unknown"
UP = "up"
DOWN = "down"
OVERDUE = "overdue"
def __init__(self, host, cid, addr, afam):
self.host = host
@@ -39,7 +39,7 @@ class Connection:
self.lastbeat = time.time()
self.statetime = self.lastbeat
self.deltastatetime = "computed"
self.state = Connection.unknown
self.state = Connection.UNKNOWN
if host:
Connection.htab[addr] = self.host.name
@@ -57,18 +57,18 @@ class Connection:
d["addr"] = self.addr
if self.rtts[-1]:
d["rtt"] = "%0.1f" % self.rtts[-1]
elif self.state == Connection.unknown:
elif self.state == Connection.UNKNOWN:
d["rtt"] = ""
else:
d["rtt"] = "?"
d["lastbeat"] = self.lastbeat
if self.state == Connection.overdue:
if self.state == Connection.OVERDUE:
d["state"] = "<b>%s</b>" % self.state
else:
d["state"] = self.state
if self.state == Connection.up:
if self.state == Connection.UP:
d["rttstate"] = d["rtt"]
elif self.state == Connection.overdue:
elif self.state == Connection.OVERDUE:
d["rttstate"] = ""
else:
d["rttstate"] = d["state"]
@@ -77,7 +77,7 @@ class Connection:
)
delta = now - self.statetime
if self.state == Connection.unknown:
if self.state == Connection.UNKNOWN:
d["deltastatetime"] = ""
elif delta > 86400:
# d['deltastatetime'] = time.strftime("%d %H:%M:%S", time.gmtime(delta))