mirror of https://github.com/MISP/misp-dashboard
chg: [diagnostic] Added support of multiple subscribers - WiP
parent
cbbdf7cbfc
commit
a9f9a67184
|
@ -172,7 +172,10 @@ def check_zmq(spinner):
|
||||||
timeout = 15
|
timeout = 15
|
||||||
context = zmq.Context()
|
context = zmq.Context()
|
||||||
socket = context.socket(zmq.SUB)
|
socket = context.socket(zmq.SUB)
|
||||||
socket.connect(configuration_file.get('RedisGlobal', 'zmq_url'))
|
misp_instances = json.loads(cfg.get('RedisGlobal', 'misp_instances'))
|
||||||
|
instances_status = {}
|
||||||
|
for misp_instance in misp_instances:
|
||||||
|
socket.connect(misp_instance.get('zmq'))
|
||||||
socket.setsockopt_string(zmq.SUBSCRIBE, '')
|
socket.setsockopt_string(zmq.SUBSCRIBE, '')
|
||||||
poller = zmq.Poller()
|
poller = zmq.Poller()
|
||||||
|
|
||||||
|
@ -184,10 +187,20 @@ def check_zmq(spinner):
|
||||||
if socket in socks and socks[socket] == zmq.POLLIN:
|
if socket in socks and socks[socket] == zmq.POLLIN:
|
||||||
rcv_string = socket.recv()
|
rcv_string = socket.recv()
|
||||||
if rcv_string.startswith(b'misp_json'):
|
if rcv_string.startswith(b'misp_json'):
|
||||||
return (True, '')
|
instances_status[misp_instance.get('name')] = True
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
spinner.text = f'checking zmq - elapsed time: {int(time.time() - start_time)}s'
|
spinner.text = f'checking zmq of {misp_instance.get('name')} - elapsed time: {int(time.time() - start_time)}s'
|
||||||
|
instances_status[misp_instance.get('name')] = False
|
||||||
|
|
||||||
|
results = [s for n, s in instances_status.items()]
|
||||||
|
if all(results):
|
||||||
|
return (True, '')
|
||||||
|
elif any(results):
|
||||||
|
return_text = 'Some connection to ZMQ streams failed.\n'
|
||||||
|
for name, status:
|
||||||
|
return_text += f'\t➥ {name}: {'success' if status else 'failed'}\n'
|
||||||
|
return (True, return_text)
|
||||||
else:
|
else:
|
||||||
return (False, '''Can\'t connect to the ZMQ stream.
|
return (False, '''Can\'t connect to the ZMQ stream.
|
||||||
\t➥ Make sure the MISP ZMQ is running: `/servers/serverSettings/diagnostics`
|
\t➥ Make sure the MISP ZMQ is running: `/servers/serverSettings/diagnostics`
|
||||||
|
|
Loading…
Reference in New Issue