start html cleanup
This commit is contained in:
@@ -275,7 +275,6 @@ class Host:
|
||||
a.append([])
|
||||
except:
|
||||
self.connections={}
|
||||
self.connections={}
|
||||
|
||||
|
||||
def getstate(self):
|
||||
@@ -289,15 +288,16 @@ class Host:
|
||||
state = ""
|
||||
for x in self.connections.keys():
|
||||
try:
|
||||
state += " %5.1f" % self.connections[x].rtts[-1]
|
||||
state += " %5.1f" % (self.connections[x].rtts[-1])
|
||||
except:
|
||||
state += " %5s" % self.connections[x].rtts[-1]
|
||||
state += " %5s" % (self.connections[x].rtts[-1])
|
||||
else:
|
||||
state = "%s" % self.state
|
||||
return state
|
||||
|
||||
|
||||
def dispstats(self):
|
||||
return '<td align="right">N/A</td><td></td<td></td>'
|
||||
if self.doesack != -1:
|
||||
if self.upcount > 0:
|
||||
# return "(%0.1f%%) %s %s %s " % ((self.doesack * 100.0) / self.upcount, self.doesack, self.upcount, self.hdwcounts)
|
||||
@@ -317,6 +317,19 @@ class Host:
|
||||
return '<td align="right">N/A</td><td></td<td></td>>'
|
||||
|
||||
|
||||
def htmldisp(self, header=False):
|
||||
if header:
|
||||
return "<tr><th>Host</th><th>State</th><th>Hr</th><th>Dy</th><th>Wk</th><th>IP4 Addr</th><th>IP6 Addr</th><th>Last change</th><th>Ver</th></tr>\n"
|
||||
|
||||
else:
|
||||
ipv4addr = self.addr4 if self.addr4 else ""
|
||||
ipv6addr = self.addr6 if self.addr6 else ""
|
||||
lastts = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(self.statetime))
|
||||
return "<tr><td>%-24s</td><td>%-7s</td>%s<td>%-16s</td><td>%-16s</td><td>%-17s</td><td>%s</td></tr>\n" % \
|
||||
(self.name, self.dispstate(), self.dispstats(), ipv4addr, ipv6addr, lastts, self.cver)
|
||||
|
||||
|
||||
|
||||
# set new state, return number of secs in previous state
|
||||
def newstate(self, state, when=0):
|
||||
self.state = state
|
||||
@@ -584,7 +597,7 @@ def readsock(sock):
|
||||
log(name, "shutdown")
|
||||
if name in watchhosts:
|
||||
email("shutdown", "%s shutdown" % name)
|
||||
pushover(m)
|
||||
pushover("%s hbc shutdown" % name)
|
||||
try:
|
||||
host.newstate(Host.down)
|
||||
except:
|
||||
@@ -692,12 +705,11 @@ class HttpHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||
res.append("<H2>Heartbeat status %s</h2><h4> %s (%s)</H4>" % (VER, time.strftime("%H:%M:%S", time.localtime(now)), os.environ.get('TZ', 'CET-1CDT')))
|
||||
|
||||
res.append("<table>")
|
||||
res.append("<tr><th>Host</th><th>State</th><th>Hr</th><th>Dy</th><th>Wk</th><th>IP4 Addr</th><th>IP6 Addr</th><th>Last change</th><th>Ver</th></tr>\n")
|
||||
hosts_sorted = hosts.keys()
|
||||
hosts_sorted.sort()
|
||||
res.append(hosts[hosts_sorted[0]].htmldisp(True))
|
||||
for h in hosts_sorted:
|
||||
res.append("<tr><td>%-24s</td><td>%-7s</td>%s<td>%-16s</td><td>%-16s</td><td>%-17s</td><td>%s</td></tr>\n" % \
|
||||
(h, hosts[h].dispstate(), hosts[h].dispstats(), hosts[h].addr4, hosts[h].addr6, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(hosts[h].statetime)), hosts[h].cver))
|
||||
res.append(hosts[h].htmldisp())
|
||||
res.append("</table>")
|
||||
|
||||
le = max(40 - len(hosts), 3)
|
||||
|
||||
Reference in New Issue
Block a user