mirror of https://github.com/D4-project/d4-core
chg: [UI sensor_status] refractor: use datatable + display sensor types + description
TODO: edit desriptionpull/23/head
parent
3a22c250ee
commit
1dd57366c2
|
@ -0,0 +1,82 @@
|
||||||
|
# D4 core
|
||||||
|
|
||||||
|
![](https://www.d4-project.org/assets/images/logo.png)
|
||||||
|
|
||||||
|
## D4 core server
|
||||||
|
|
||||||
|
D4 core server is a complete server to handle clients (sensors) including the decapsulation of the [D4 protocol](https://github.com/D4-project/architecture/tree/master/format), control of
|
||||||
|
sensor registrations, management of decoding protocols and dispatching to adequate decoders/analysers.
|
||||||
|
|
||||||
|
## Database map
|
||||||
|
|
||||||
|
| Key | Value |
|
||||||
|
| --- | --- |
|
||||||
|
| | |
|
||||||
|
| | | |
|
||||||
|
|
||||||
|
### Server
|
||||||
|
| Key | Value |
|
||||||
|
| --- | --- |
|
||||||
|
| server:hmac_default_key | **hmac_default_key** |
|
||||||
|
|
||||||
|
| Set Key | Value |
|
||||||
|
| --- | --- |
|
||||||
|
| server:accepted_type | **accepted type** |
|
||||||
|
| server:accepted_extended_type | **accepted extended type** |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Stats
|
||||||
|
| Zset Key | Field | Value |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| stat_uuid_ip:**date**:**uuid** | **IP** | **number D4 Packets** |
|
||||||
|
| | | |
|
||||||
|
| stat_uuid_type:**date**:**uuid** | **type** | **number D4 Packets** |
|
||||||
|
| | | |
|
||||||
|
| stat_type_uuid:**date**:**type** | **uuid** | **number D4 Packets** |
|
||||||
|
| | | |
|
||||||
|
| stat_ip_uuid:20190519:158.64.14.86 | **uuid** | **number D4 Packets** |
|
||||||
|
| | | |
|
||||||
|
| | | |
|
||||||
|
| daily_uuid:**date** | **uuid** | **number D4 Packets** |
|
||||||
|
| | | |
|
||||||
|
| daily_type:**date** | **type** | **number D4 Packets** |
|
||||||
|
| | | |
|
||||||
|
| daily_ip:**date** | **IP** | **number D4 Packets** |
|
||||||
|
|
||||||
|
### metadata sensors
|
||||||
|
| Hset Key | Field | Value |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| metadata_uuid:**uuid** | first_seen | **epoch** |
|
||||||
|
| | last_seen | **epoch** |
|
||||||
|
| | description | **description** |
|
||||||
|
| | Error | **error message** |
|
||||||
|
|
||||||
|
###### Last IP
|
||||||
|
| List Key | Value |
|
||||||
|
| --- | --- |
|
||||||
|
| list_uuid_ip:**uuid** | **IP** |
|
||||||
|
|
||||||
|
### metadata types by sensors
|
||||||
|
| Hset Key | Field | Value |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| metadata_uuid:**uuid** | first_seen | **epoch** |
|
||||||
|
| | last_seen | **epoch** |
|
||||||
|
|
||||||
|
| Set Key | Value |
|
||||||
|
| --- | --- |
|
||||||
|
| all_types_by_uuid:**uuid** | **type** |
|
||||||
|
|
||||||
|
### analyzers
|
||||||
|
###### metadata
|
||||||
|
| Hset Key | Field | Value |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| analyzer:**uuid** | last_updated | **epoch** |
|
||||||
|
| | description | **description** |
|
||||||
|
| | max_size | **queue max size** |
|
||||||
|
|
||||||
|
###### all analyzers by type
|
||||||
|
| Set Key | Value |
|
||||||
|
| --- | --- |
|
||||||
|
| analyzer:**type** | **uuid** |
|
||||||
|
| analyzer:254:**extended type** | **uuid** |
|
|
@ -200,7 +200,6 @@ def page_not_found(e):
|
||||||
# ========== ROUTES ============
|
# ========== ROUTES ============
|
||||||
@app.route('/test')
|
@app.route('/test')
|
||||||
def test():
|
def test():
|
||||||
print(get_uuid_disk_statistics('fae58cdc30024239874f4c7ce53fbf4d', date_day='20190527'))
|
|
||||||
return 'test'
|
return 'test'
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
|
@ -259,6 +258,9 @@ def sensors_status():
|
||||||
first_seen_gmt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(first_seen)))
|
first_seen_gmt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(first_seen)))
|
||||||
last_seen = redis_server_metadata.hget('metadata_uuid:{}'.format(result), 'last_seen')
|
last_seen = redis_server_metadata.hget('metadata_uuid:{}'.format(result), 'last_seen')
|
||||||
last_seen_gmt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(last_seen)))
|
last_seen_gmt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(last_seen)))
|
||||||
|
description = redis_server_metadata.hget('metadata_uuid:{}'.format(result), 'description')
|
||||||
|
l_uuid_types = list(redis_server_metadata.smembers('all_types_by_uuid:{}'.format(result)))
|
||||||
|
l_uuid_types.sort()
|
||||||
if redis_server_metadata.sismember('blacklist_ip_by_uuid', result):
|
if redis_server_metadata.sismember('blacklist_ip_by_uuid', result):
|
||||||
Error = "All IP using this UUID are Blacklisted"
|
Error = "All IP using this UUID are Blacklisted"
|
||||||
elif redis_server_metadata.sismember('blacklist_uuid', result):
|
elif redis_server_metadata.sismember('blacklist_uuid', result):
|
||||||
|
@ -272,8 +274,9 @@ def sensors_status():
|
||||||
|
|
||||||
if first_seen is not None and last_seen is not None:
|
if first_seen is not None and last_seen is not None:
|
||||||
status_daily_uuid.append({"uuid": result,"first_seen": first_seen, "last_seen": last_seen,
|
status_daily_uuid.append({"uuid": result,"first_seen": first_seen, "last_seen": last_seen,
|
||||||
"active_connection": active_connection,
|
"active_connection": active_connection, "description": description,
|
||||||
"first_seen_gmt": first_seen_gmt, "last_seen_gmt": last_seen_gmt, "Error": Error})
|
"first_seen_gmt": first_seen_gmt, "last_seen_gmt": last_seen_gmt,
|
||||||
|
"l_uuid_types": l_uuid_types, "Error": Error})
|
||||||
|
|
||||||
return render_template("sensors_status.html", status_daily_uuid=status_daily_uuid,
|
return render_template("sensors_status.html", status_daily_uuid=status_daily_uuid,
|
||||||
active_connection_filter=active_connection_filter)
|
active_connection_filter=active_connection_filter)
|
||||||
|
|
|
@ -7,10 +7,13 @@
|
||||||
<!-- Core CSS -->
|
<!-- Core CSS -->
|
||||||
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
||||||
<link href="{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel="stylesheet">
|
<link href="{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel="stylesheet">
|
||||||
|
<link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet">
|
||||||
|
|
||||||
<!-- JS -->
|
<!-- JS -->
|
||||||
<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/bootstrap.min.js')}}"></script>
|
<script src="{{ url_for('static', filename='js/bootstrap.min.js')}}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
|
@ -63,56 +66,64 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% for row_uuid in status_daily_uuid %}
|
<div class="mx-2">
|
||||||
<div class="card text-center mt-3 ml-2 mr-2">
|
<table class="table table-striped table-bordered table-hover text-center" id="myTable_1">
|
||||||
<a class="btn btn-outline-dark px-1 py-1" href="{{ url_for('uuid_management') }}?uuid={{row_uuid['uuid']}}">
|
<thead>
|
||||||
<div class="card-header bg-dark text-white">
|
<tr>
|
||||||
UUID: {{row_uuid['uuid']}}
|
<th class="bg-info text-white">UUID</th>
|
||||||
</div>
|
<th class="bg-info text-white">first seen</th>
|
||||||
</a>
|
<th class="bg-info text-white">last seen</th>
|
||||||
<div class="card-body">
|
<th class="bg-info text-white">types</th>
|
||||||
<div class="card-group">
|
<th class="bg-secondary text-white">Status</th>
|
||||||
<div class="card">
|
</tr>
|
||||||
<div class="card-header bg-info text-white">
|
</thead>
|
||||||
First Seen
|
<tbody>
|
||||||
</div>
|
{% for row_uuid in status_daily_uuid %}
|
||||||
<div class="card-body">
|
<tr>
|
||||||
<p class="card-text">{{row_uuid['first_seen_gmt']}} - ({{row_uuid['first_seen']}})</p>
|
<td>
|
||||||
</div>
|
<a class="" href="{{ url_for('uuid_management') }}?uuid={{row_uuid['uuid']}}">
|
||||||
</div>
|
{{row_uuid['uuid']}}
|
||||||
<div class="card">
|
</a>
|
||||||
<div class="card-header bg-info text-white">
|
<div class="text-info"><small>{{row_uuid['description']}}</small></div>
|
||||||
Last Seen
|
</td>
|
||||||
</div>
|
<td>{{row_uuid['first_seen_gmt']}} - ({{row_uuid['first_seen']}})</td>
|
||||||
<div class="card-body">
|
<td>{{row_uuid['last_seen_gmt']}} - ({{row_uuid['last_seen']}})</td>
|
||||||
<p class="card-text">{{row_uuid['last_seen_gmt']}} - ({{row_uuid['last_seen']}})</p>
|
<td>
|
||||||
</div>
|
{% for uuid_type in row_uuid['l_uuid_types'] %}
|
||||||
</div>
|
<span class="badge badge-dark">{{uuid_type}}</span>
|
||||||
<div class="card">
|
{% endfor %}
|
||||||
{% if not row_uuid['Error'] %}
|
</td>
|
||||||
<div class="card-header bg-success text-white">
|
<td
|
||||||
Status
|
{% if not row_uuid['Error'] %}
|
||||||
</div>
|
div class="text-success">
|
||||||
<div class="card-body text-success">
|
OK -
|
||||||
<p class="card-text">OK</p>
|
{% else %}
|
||||||
{% else %}
|
div class="text-danger">
|
||||||
<div class="card-header bg-danger text-white">
|
<i class="fa fa-times-circle"></i> {{row_uuid['Error']}}
|
||||||
Status
|
|
||||||
</div>
|
|
||||||
<div class="card-body text-danger">
|
|
||||||
<p class="card-text">{{row_uuid['Error']}}</p>
|
|
||||||
{% endif %}
|
|
||||||
{% if row_uuid['active_connection'] %}
|
|
||||||
<div style="color:Green; display:inline-block">
|
|
||||||
<i class="fa fa-check-circle"></i> Connected
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
{% if row_uuid['active_connection'] %}
|
||||||
</div>
|
<i class="fa fa-check-circle"></i> Connected
|
||||||
</div>
|
{% endif %}
|
||||||
</div>
|
</td>
|
||||||
</div>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% include 'navfooter.html' %}
|
{% include 'navfooter.html' %}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
table = $('#myTable_1').DataTable(
|
||||||
|
{
|
||||||
|
"aLengthMenu": [[5, 10, 15, 20, -1], [5, 10, 15, 20, "All"]],
|
||||||
|
"iDisplayLength": 10,
|
||||||
|
"order": [[ 0, "asc" ]]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue