From 714570636f39dacb4bd6999a3b6279fce8fe4fca Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Tue, 26 Apr 2016 23:12:43 +0200 Subject: [PATCH] hack to work around compound object json --- hbd | 2 +- hbdclass.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hbd b/hbd index cd23464..a3c42ec 100755 --- a/hbd +++ b/hbd @@ -308,7 +308,7 @@ def checkoverdue(): if h in watchhosts: email("overdue", "%s overdue" % ",".join(pmsg)) pushover("%s %s overdue" % (h, join(pmsg))) - lof(h, "%s overdue" % join(pmsg)) + log(h, "%s overdue" % " and ".join(pmsg)) def log(host, m, service=None): diff --git a/hbdclass.py b/hbdclass.py index f3261c1..7005a3c 100644 --- a/hbdclass.py +++ b/hbdclass.py @@ -7,6 +7,7 @@ the websit's heartbeat.py import time import json +import copy num = 0 @@ -118,6 +119,9 @@ class Host: def __init__(self, name): global num self.name = name + if name: + num += 1 + Host.hosts[name] = self self.num = num self.dyn = False self.upcount = 0 @@ -127,9 +131,6 @@ class Host: self.cver = 0 self.connections = {} self.hdwcounts = [[0,0],[0,0],[0,0]] - if name: - num += 1 - Host.hosts[name] = self def statedict(self): @@ -169,7 +170,10 @@ class Host: if d == 'connections': cl = [] for c in self.connections: - cl.append(self.connections[c].__dict__) + # dirty ugly hack: fix conn to host backpointer + cld = copy.deepcopy(self.connections[c].__dict__) + cld['host'] = cld['host'].name + cl.append(cld) ddict[d] = cl else: ddict[d] = self.__dict__[d]