diff --git a/hbc b/hbc
index 9251852..a51fcc4 100755
--- a/hbc
+++ b/hbc
@@ -369,7 +369,6 @@ except:
for o,a in optlist:
if o == '-b':
msgboot['boot']=1
- msgonly=True
elif o == '-c':
configfile=a
cmdargs += [o, a]
@@ -486,7 +485,7 @@ if msgonly:
#
-syslog.openlog(logoption=syslog.LOG_PID, facility=syslog.LOG_DAEMON)
+syslog.openlog('hbc', syslog.LOG_PID, syslog.LOG_DAEMON)
if fdaemon:
pidfile = daemon.pidfile.TimeoutPIDLockFile(PIDFILE, acquire_timeout=-1)
diff --git a/hbd b/hbd
index dfe1fe1..b24cf27 100755
--- a/hbd
+++ b/hbd
@@ -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 '
N/A | | '
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 'N/A | | >'
+ def htmldisp(self, header=False):
+ if header:
+ return "| Host | State | Hr | Dy | Wk | IP4 Addr | IP6 Addr | Last change | Ver |
\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 "| %-24s | %-7s | %s%-16s | %-16s | %-17s | %s |
\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("Heartbeat status %s
%s (%s)
" % (VER, time.strftime("%H:%M:%S", time.localtime(now)), os.environ.get('TZ', 'CET-1CDT')))
res.append("")
- res.append("| Host | State | Hr | Dy | Wk | IP4 Addr | IP6 Addr | Last change | Ver |
\n")
hosts_sorted = hosts.keys()
hosts_sorted.sort()
+ res.append(hosts[hosts_sorted[0]].htmldisp(True))
for h in hosts_sorted:
- res.append("| %-24s | %-7s | %s%-16s | %-16s | %-17s | %s |
\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("
")
le = max(40 - len(hosts), 3)