|
@@ -101,14 +101,18 @@ def from_livestatus(get, query=[], columns=[]):
|
|
|
else:
|
|
|
Line = None
|
|
|
lines = []
|
|
|
- with socket.create_connection(("nucnagios.tetaneutral.net", "8622")) as sock:
|
|
|
- sock.send(query.encode('utf-8'))
|
|
|
- sock.shutdown(socket.SHUT_WR)
|
|
|
- infile = sock.makefile(encoding='utf-8')
|
|
|
- data = json.load(infile)
|
|
|
- for entry in data:
|
|
|
- if not Line:
|
|
|
- Line = namedtuple(get.capitalize(), entry)
|
|
|
- continue
|
|
|
- lines.append(Line(*entry))
|
|
|
+ try:
|
|
|
+ with socket.create_connection(("nucnagios.tetaneutral.net", "8622")) as sock:
|
|
|
+ sock.send(query.encode('utf-8'))
|
|
|
+ sock.shutdown(socket.SHUT_WR)
|
|
|
+ infile = sock.makefile(encoding='utf-8')
|
|
|
+ data = json.load(infile)
|
|
|
+ except ConnectionResetError:
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ for entry in data:
|
|
|
+ if not Line:
|
|
|
+ Line = namedtuple(get.capitalize(), entry)
|
|
|
+ continue
|
|
|
+ lines.append(Line(*entry))
|
|
|
return lines
|