chg: [worker] trim analyser queue + fix UI fcts

pull/8/head
Terrtia 2019-02-01 16:55:48 +01:00
parent f94480baec
commit ad0db0e6e8
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
3 changed files with 24 additions and 2 deletions

View File

@ -43,12 +43,19 @@ redis_server_metadata = redis.StrictRedis(
db=0,
decode_responses=True)
redis_server_analyzer = redis.StrictRedis(
host=host_redis_metadata,
port=port_redis_metadata,
db=2,
decode_responses=True)
app = Flask(__name__, static_url_path=baseUrl+'/static/')
app.config['MAX_CONTENT_LENGTH'] = 900 * 1024 * 1024
# ========== FUNCTIONS ============
def is_valid_uuid_v4(header_uuid):
try:
header_uuid=header_uuid.replace('-', '')
uuid_test = uuid.UUID(hex=header_uuid, version=4)
return uuid_test.hex == header_uuid
except:
@ -371,7 +378,8 @@ def remove_analyzer():
except:
return 'type, Invalid Integer'
redis_server_metadata.srem('analyzer:{}'.format(type), analyzer_uuid)
print(user)
redis_server_analyzer.delete('analyzer:{}:{}'.format(type, analyzer_uuid))
redis_server_metadata.delete('analyzer:{}'.format(analyzer_uuid))
if user:
return redirect(url_for('server_management'))
else:

View File

@ -199,7 +199,7 @@
<div class="row">
<div class="col-sm-8">
<table class="table table-striped table-bordered table-hover" id="myTable_">
<table class="table table-striped table-bordered table-hover" id="myTable_1">
<thead class="thead-dark">
<tr>
<th>Type</th>
@ -267,5 +267,13 @@ $(document).ready(function(){
}
);
table = $('#myTable_1').DataTable(
{
/*"aLengthMenu": [[5, 10, 15, 20, -1], [5, 10, 15, 20, "All"]],
"iDisplayLength": 10,*/
"order": [[ 0, "asc" ]]
}
);
});
</script>

View File

@ -35,6 +35,8 @@ redis_server_analyzer = redis.StrictRedis(
type = 8
rotation_save_cycle = 300 #seconds
analyzer_list_max_default_size = 10000
save_to_file = True
def get_save_dir(dir_data_uuid, year, month, day):
@ -100,6 +102,10 @@ if __name__ == "__main__":
analyzer_uuid = analyzer_uuid.decode()
redis_server_analyzer.lpush('analyzer:{}:{}'.format(type, analyzer_uuid), line)
redis_server_metadata.hset('analyzer:{}'.format(analyzer_uuid), 'last_updated', time.time())
analyser_queue_max_size = redis_server_metadata.hget('analyzer:{}'.format(analyzer_uuid), 'max_size')
if analyser_queue_max_size is None:
analyser_queue_max_size = analyzer_list_max_default_size
redis_server_analyzer.ltrim('analyzer:{}:{}'.format(type, analyzer_uuid), 0, analyser_queue_max_size)
# keep incomplete line
if all_line[-1] != b'':
buffer += data[b'message']