More stuff
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# $Id: hbd,v 1.7 2005/07/21 18:07:33 andreas Exp $
|
||||
# $Id: hbd,v 1.8 2006/01/21 17:52:27 andreas Exp $
|
||||
# Wait for heartbeat messages and act on them (or their absence)
|
||||
#
|
||||
import time, os, string, sys, socket, atexit, select, SocketServer, getopt
|
||||
@@ -57,9 +57,9 @@ class Host:
|
||||
return self.state
|
||||
|
||||
# set new state, return number of secs in previous state
|
||||
def newstate(self, state):
|
||||
def newstate(self, state, when=0):
|
||||
self.state=state
|
||||
now=time.time()
|
||||
now=time.time()-when
|
||||
s=now-self.statetime
|
||||
self.statetime=now
|
||||
if visual:
|
||||
@@ -151,12 +151,13 @@ def checkoverdue():
|
||||
if hosts[h].state == Host.down:
|
||||
continue
|
||||
if reportstrict:
|
||||
timeout=hosts[h].interval+grace
|
||||
gr=grace
|
||||
else:
|
||||
timeout=hosts[h].interval*5+grace
|
||||
gr=5*grace
|
||||
timeout=hosts[h].interval+gr
|
||||
if hosts[h].state == Host.up and now-hosts[h].lastbeat > timeout:
|
||||
if reportstrict: log("%s is overdue" % h)
|
||||
hosts[h].newstate(Host.overdue)
|
||||
log("%s is overdue" % h)
|
||||
hosts[h].newstate(Host.overdue, gr)
|
||||
|
||||
#
|
||||
#
|
||||
@@ -487,7 +488,7 @@ if f:
|
||||
elif r[0] == 'logfmt':
|
||||
logfmt=r[1]
|
||||
elif r[0] == 'reportstrict':
|
||||
reportstrict=r[1]
|
||||
reportstrict=r[1] in ["True","true","TRUE","1"]
|
||||
f.close()
|
||||
|
||||
if len(args) != 0:
|
||||
|
||||
Reference in New Issue
Block a user