hack to work around compound object json

This commit is contained in:
2016-04-26 23:12:43 +02:00
parent 21f8fe8842
commit 714570636f
2 changed files with 9 additions and 5 deletions
+1 -1
View File
@@ -308,7 +308,7 @@ def checkoverdue():
if h in watchhosts: if h in watchhosts:
email("overdue", "%s overdue" % ",".join(pmsg)) email("overdue", "%s overdue" % ",".join(pmsg))
pushover("%s %s overdue" % (h, 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): def log(host, m, service=None):
+8 -4
View File
@@ -7,6 +7,7 @@ the websit's heartbeat.py
import time import time
import json import json
import copy
num = 0 num = 0
@@ -118,6 +119,9 @@ class Host:
def __init__(self, name): def __init__(self, name):
global num global num
self.name = name self.name = name
if name:
num += 1
Host.hosts[name] = self
self.num = num self.num = num
self.dyn = False self.dyn = False
self.upcount = 0 self.upcount = 0
@@ -127,9 +131,6 @@ class Host:
self.cver = 0 self.cver = 0
self.connections = {} self.connections = {}
self.hdwcounts = [[0,0],[0,0],[0,0]] self.hdwcounts = [[0,0],[0,0],[0,0]]
if name:
num += 1
Host.hosts[name] = self
def statedict(self): def statedict(self):
@@ -169,7 +170,10 @@ class Host:
if d == 'connections': if d == 'connections':
cl = [] cl = []
for c in self.connections: 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 ddict[d] = cl
else: else:
ddict[d] = self.__dict__[d] ddict[d] = self.__dict__[d]