cpitalize constants
This commit is contained in:
@@ -423,12 +423,12 @@ def checkoverdue():
|
|||||||
continue
|
continue
|
||||||
timeout = hbdclass.Host.hosts[h].interval + grace
|
timeout = hbdclass.Host.hosts[h].interval + grace
|
||||||
if conn.state == hbdclass.Connection.up and (now - conn.lastbeat) > timeout:
|
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)
|
pmsg.append(conn.afam)
|
||||||
if (
|
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 pmsg != []:
|
||||||
if h in watchhosts:
|
if h in watchhosts:
|
||||||
email("overdue", "%s overdue" % " and ".join(pmsg))
|
email("overdue", "%s overdue" % " and ".join(pmsg))
|
||||||
|
|||||||
+10
-10
@@ -25,10 +25,10 @@ class Connection:
|
|||||||
# map of addrs to names
|
# map of addrs to names
|
||||||
|
|
||||||
htab = {}
|
htab = {}
|
||||||
unknown = "unknown"
|
UNKNOWN = "unknown"
|
||||||
up = "up"
|
UP = "up"
|
||||||
down = "down"
|
DOWN = "down"
|
||||||
overdue = "overdue"
|
OVERDUE = "overdue"
|
||||||
|
|
||||||
def __init__(self, host, cid, addr, afam):
|
def __init__(self, host, cid, addr, afam):
|
||||||
self.host = host
|
self.host = host
|
||||||
@@ -39,7 +39,7 @@ class Connection:
|
|||||||
self.lastbeat = time.time()
|
self.lastbeat = time.time()
|
||||||
self.statetime = self.lastbeat
|
self.statetime = self.lastbeat
|
||||||
self.deltastatetime = "computed"
|
self.deltastatetime = "computed"
|
||||||
self.state = Connection.unknown
|
self.state = Connection.UNKNOWN
|
||||||
|
|
||||||
if host:
|
if host:
|
||||||
Connection.htab[addr] = self.host.name
|
Connection.htab[addr] = self.host.name
|
||||||
@@ -57,18 +57,18 @@ class Connection:
|
|||||||
d["addr"] = self.addr
|
d["addr"] = self.addr
|
||||||
if self.rtts[-1]:
|
if self.rtts[-1]:
|
||||||
d["rtt"] = "%0.1f" % self.rtts[-1]
|
d["rtt"] = "%0.1f" % self.rtts[-1]
|
||||||
elif self.state == Connection.unknown:
|
elif self.state == Connection.UNKNOWN:
|
||||||
d["rtt"] = ""
|
d["rtt"] = ""
|
||||||
else:
|
else:
|
||||||
d["rtt"] = "?"
|
d["rtt"] = "?"
|
||||||
d["lastbeat"] = self.lastbeat
|
d["lastbeat"] = self.lastbeat
|
||||||
if self.state == Connection.overdue:
|
if self.state == Connection.OVERDUE:
|
||||||
d["state"] = "<b>%s</b>" % self.state
|
d["state"] = "<b>%s</b>" % self.state
|
||||||
else:
|
else:
|
||||||
d["state"] = self.state
|
d["state"] = self.state
|
||||||
if self.state == Connection.up:
|
if self.state == Connection.UP:
|
||||||
d["rttstate"] = d["rtt"]
|
d["rttstate"] = d["rtt"]
|
||||||
elif self.state == Connection.overdue:
|
elif self.state == Connection.OVERDUE:
|
||||||
d["rttstate"] = ""
|
d["rttstate"] = ""
|
||||||
else:
|
else:
|
||||||
d["rttstate"] = d["state"]
|
d["rttstate"] = d["state"]
|
||||||
@@ -77,7 +77,7 @@ class Connection:
|
|||||||
)
|
)
|
||||||
delta = now - self.statetime
|
delta = now - self.statetime
|
||||||
|
|
||||||
if self.state == Connection.unknown:
|
if self.state == Connection.UNKNOWN:
|
||||||
d["deltastatetime"] = ""
|
d["deltastatetime"] = ""
|
||||||
elif delta > 86400:
|
elif delta > 86400:
|
||||||
# d['deltastatetime'] = time.strftime("%d %H:%M:%S", time.gmtime(delta))
|
# d['deltastatetime'] = time.strftime("%d %H:%M:%S", time.gmtime(delta))
|
||||||
|
|||||||
Reference in New Issue
Block a user