mirror of https://github.com/MISP/misp-dashboard
chg: [diagnostic] Added info about elapsed time
parent
f3f2c0d4bf
commit
d442a40175
|
@ -163,19 +163,25 @@ def check_redis(spinner):
|
||||||
|
|
||||||
@add_spinner
|
@add_spinner
|
||||||
def check_zmq(spinner):
|
def check_zmq(spinner):
|
||||||
|
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'))
|
socket.connect(configuration_file.get('RedisGlobal', 'zmq_url'))
|
||||||
socket.setsockopt_string(zmq.SUBSCRIBE, '')
|
socket.setsockopt_string(zmq.SUBSCRIBE, '')
|
||||||
poller = zmq.Poller()
|
poller = zmq.Poller()
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
poller.register(socket, zmq.POLLIN)
|
poller.register(socket, zmq.POLLIN)
|
||||||
socks = dict(poller.poll(timeout=15000))
|
for t in range(1, timeout+1):
|
||||||
if len(socks) > 0:
|
socks = dict(poller.poll(timeout=1*1000))
|
||||||
if socket in socks and socks[socket] == zmq.POLLIN:
|
if len(socks) > 0:
|
||||||
rcv_string = socket.recv()
|
if socket in socks and socks[socket] == zmq.POLLIN:
|
||||||
if rcv_string.startswith(b'misp_json'):
|
rcv_string = socket.recv()
|
||||||
return (True, '')
|
if rcv_string.startswith(b'misp_json'):
|
||||||
|
return (True, '')
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
spinner.text = f'checking zmq - elapsed time: {int(time.time() - start_time)}s'
|
||||||
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`
|
||||||
|
@ -215,6 +221,7 @@ def check_subscriber_status(spinner):
|
||||||
monitor = diagnostic_util.Monitor(pool)
|
monitor = diagnostic_util.Monitor(pool)
|
||||||
commands = monitor.monitor()
|
commands = monitor.monitor()
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
signal.alarm(15)
|
signal.alarm(15)
|
||||||
try:
|
try:
|
||||||
for i, c in enumerate(commands):
|
for i, c in enumerate(commands):
|
||||||
|
@ -229,6 +236,8 @@ def check_subscriber_status(spinner):
|
||||||
if action == '"LPUSH"' and target == f'\"{configuration_file.get("RedisLIST", "listName")}\"':
|
if action == '"LPUSH"' and target == f'\"{configuration_file.get("RedisLIST", "listName")}\"':
|
||||||
signal.alarm(0)
|
signal.alarm(0)
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
spinner.text = f'Checking subscriber status - elapsed time: {int(time.time() - start_time)}s'
|
||||||
except diagnostic_util.TimeoutException:
|
except diagnostic_util.TimeoutException:
|
||||||
return_text = f'''zmq_subscriber seems not to be working.
|
return_text = f'''zmq_subscriber seems not to be working.
|
||||||
\t➥ Consider restarting it: {pgrep_subscriber_output}'''
|
\t➥ Consider restarting it: {pgrep_subscriber_output}'''
|
||||||
|
@ -280,7 +289,7 @@ def check_buffer_change_rate(spinner):
|
||||||
if next_refresh < time_slept:
|
if next_refresh < time_slept:
|
||||||
next_refresh = time_slept + refresh_frequency
|
next_refresh = time_slept + refresh_frequency
|
||||||
change_rate_text = f'↑ {change_increase}/sec\t↓ {change_decrease}/sec'
|
change_rate_text = f'↑ {change_increase}/sec\t↓ {change_decrease}/sec'
|
||||||
spinner.text = f'Buffer: {elements_in_list}\t, {change_rate_text}'
|
spinner.text = f'Buffer: {elements_in_list}\t{change_rate_text}'
|
||||||
|
|
||||||
if consecutive_no_rate_change == 3:
|
if consecutive_no_rate_change == 3:
|
||||||
time_slept = sleep_max
|
time_slept = sleep_max
|
||||||
|
@ -363,6 +372,8 @@ def check_server_dynamic_enpoint(spinner):
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
bufsize=1)
|
bufsize=1)
|
||||||
signal.alarm(sleep_max)
|
signal.alarm(sleep_max)
|
||||||
|
return_flag = False
|
||||||
|
return_text = f'Dynamic endpoint returned data but not in the correct format.'
|
||||||
try:
|
try:
|
||||||
for line in iter(p.stdout.readline, b''):
|
for line in iter(p.stdout.readline, b''):
|
||||||
if line.startswith(b'data: '):
|
if line.startswith(b'data: '):
|
||||||
|
|
Loading…
Reference in New Issue