From f9bd84f7cc7ff12730af9533d6b32fa19a55e024 Mon Sep 17 00:00:00 2001 From: andreas Date: Sat, 21 Jan 2006 17:52:27 +0000 Subject: [PATCH] More stuff --- hbd | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hbd b/hbd index 0e9def2..a3b9703 100755 --- a/hbd +++ b/hbd @@ -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: