move page builder function into Host class
This commit is contained in:
@@ -306,8 +306,8 @@ def checkoverdue():
|
||||
pmsg.append(conn.afam)
|
||||
if pmsg != []:
|
||||
if h in watchhosts:
|
||||
email("overdue", "%s overdue" % ",".join(pmsg))
|
||||
pushover("%s %s overdue" % (h, join(pmsg)))
|
||||
email("overdue", "%s overdue" % " and ".join(pmsg))
|
||||
pushover("%s %s overdue" % (h, " and ".join(pmsg)))
|
||||
log(h, "%s overdue" % " and ".join(pmsg))
|
||||
|
||||
|
||||
@@ -537,23 +537,14 @@ class HttpHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||
res=self.buildhead(refresh=60, extras=tcss)
|
||||
res.append("<H2>Heartbeat status %s</h2>" % VER)
|
||||
|
||||
res.append('<table id="ntable" class="sortable">')
|
||||
res.append(ubHost.htmlheaders())
|
||||
hosts_sorted = Host.hosts.keys()
|
||||
if len(hosts_sorted):
|
||||
hosts_sorted.sort()
|
||||
for h in hosts_sorted:
|
||||
res.append(Host.hosts[h].htmldisp())
|
||||
res.append("</table>")
|
||||
|
||||
le = max(40 - len(Host.hosts), 3)
|
||||
res.append("<h4>Log of Events</h4>")
|
||||
for m in msgs[len(msgs)-le:]:
|
||||
res.append("%s<BR>" % m)
|
||||
res += ubHost.buildhosttable()
|
||||
res += ubHost.buildmsgtable(msgs)
|
||||
res.append('<p> %s (%s)</p>' % (time.strftime("%H:%M:%S", time.localtime(now)), os.environ.get('TZ', 'CET-1CDT')))
|
||||
res.append("</body></html>")
|
||||
return res
|
||||
|
||||
|
||||
def builderror(self, code, cause, lcause):
|
||||
res=[]
|
||||
res.append('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">')
|
||||
|
||||
+22
@@ -277,6 +277,28 @@ class Host:
|
||||
# (self.name, self.dispstate(), self.dispstats(), ipv4addr, ipv6addr, lastts, self.cver)
|
||||
|
||||
|
||||
def buildhosttable(self):
|
||||
res = []
|
||||
res.append('<table id="ntable" class="sortable">')
|
||||
res.append(ubHost.htmlheaders())
|
||||
hosts_sorted = Host.hosts.keys()
|
||||
if len(hosts_sorted):
|
||||
hosts_sorted.sort()
|
||||
for h in hosts_sorted:
|
||||
res.append(Host.hosts[h].htmldisp())
|
||||
res.append("</table>")
|
||||
return res
|
||||
|
||||
|
||||
def buildmsgtable(self, msgs):
|
||||
res = []
|
||||
le = max(40 - len(Host.hosts), 3)
|
||||
res.append("<h4>Log of Events</h4>")
|
||||
for m in msgs[len(msgs)-le:]:
|
||||
res.append("%s<BR>" % m)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
# create fake "unbound objects", remove in Python 3.0
|
||||
ubHost = Host(None)
|
||||
|
||||
Reference in New Issue
Block a user