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