more python 2.1 fixes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# $Id: hbd,v 1.5 2005/07/21 16:04:56 andreas Exp $
|
||||
# $Id: hbd,v 1.6 2005/07/21 17:01:28 andreas Exp $
|
||||
# Wait for heartbeat messages and act on them (or their absence)
|
||||
#
|
||||
import time, os, string, sys, socket, curses, atexit, select, SocketServer, getopt
|
||||
@@ -146,9 +146,8 @@ def initwin():
|
||||
#
|
||||
#
|
||||
def checkoverdue():
|
||||
global hosts
|
||||
|
||||
for h in hosts:
|
||||
for h in hosts.keys():
|
||||
if hosts[h].state == Host.down:
|
||||
continue
|
||||
if reportstrict:
|
||||
@@ -167,7 +166,7 @@ def displaytime():
|
||||
maxY,maxX=stdscr.getmaxyx()
|
||||
stdscr.addstr(0,maxX-8, time.strftime("%H:%M:%S", time.localtime(now)), curses.A_BOLD)
|
||||
|
||||
for h in hosts:
|
||||
for h in hosts.keys():
|
||||
d=hosts[h].getstate()
|
||||
attr=0
|
||||
if verbose and hosts[h].state != Host.down:
|
||||
@@ -197,7 +196,7 @@ def displayaddr(h, refresh=1):
|
||||
#
|
||||
#
|
||||
def displaybody():
|
||||
for h in hosts:
|
||||
for h in hosts.keys():
|
||||
win.addstr(hosts[h].num+1, 1, "%-24s" % (h))
|
||||
if hosts[h].addr != None:
|
||||
displayaddr(h, 0)
|
||||
@@ -314,7 +313,7 @@ def readsock():
|
||||
def updatestats():
|
||||
global upcount
|
||||
upcount+=1
|
||||
for h in hosts:
|
||||
for h in hosts.keys():
|
||||
if upcount > 0:
|
||||
hosts[h].uppercent="%3.0f" % ((hosts[h].upcount*hosts[h].interval*100.0)/(upcount*interval))
|
||||
#
|
||||
@@ -382,7 +381,7 @@ class HtmlHandler(SocketServer.BaseRequestHandler):
|
||||
res.append("<H2>Heartbeat status at %s</H2>" % time.strftime("%H:%M:%S", time.localtime(now)))
|
||||
res.append("<table>")
|
||||
res.append("<tr><th>Host</th><th>State</th><th>IP Addr</th><th>Res</th><th>Last change</th></tr>\n" )
|
||||
for h in hosts:
|
||||
for h in hosts.keys():
|
||||
res.append("<tr><td>%-24s</td><td>%-7s</td><td>%-16s</td><td>%-3s</td><td>%-17s</td></tr>\n" % (h, hosts[h].state, hosts[h].addr, hosts[h].uppercent, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(hosts[h].statetime))))
|
||||
res.append("</table>")
|
||||
res.append("<P>")
|
||||
|
||||
Reference in New Issue
Block a user