mirror of
https://github.com/craigerl/aprsd.git
synced 2024-12-20 16:41:13 -05:00
Added new SeenList
This patch adds the seen list feature. It tracks the callsign of every packet that aprsd sees.
This commit is contained in:
parent
004795dbf1
commit
278bb6e882
@ -302,6 +302,9 @@ class APRSDFlask(flask_classful.FlaskView):
|
||||
watch_count = 0
|
||||
watch_age = 0
|
||||
|
||||
sl = packets.SeenList()
|
||||
seen_count = len(sl.callsigns)
|
||||
|
||||
pm = plugin.PluginManager()
|
||||
plugins = pm.get_plugins()
|
||||
plugin_count = len(plugins)
|
||||
@ -343,6 +346,7 @@ class APRSDFlask(flask_classful.FlaskView):
|
||||
config_json=json.dumps(self.config.data),
|
||||
watch_count=watch_count,
|
||||
watch_age=watch_age,
|
||||
seen_count=seen_count,
|
||||
plugin_count=plugin_count,
|
||||
)
|
||||
|
||||
|
@ -50,6 +50,7 @@ class PacketList:
|
||||
else:
|
||||
self.total_recv += 1
|
||||
self.packet_list.append(packet)
|
||||
SeenList().update_seen(packet)
|
||||
|
||||
def get(self):
|
||||
with self.lock:
|
||||
@ -149,6 +150,35 @@ class WatchList:
|
||||
return False
|
||||
|
||||
|
||||
class SeenList:
|
||||
"""Global callsign seen list."""
|
||||
|
||||
_instance = None
|
||||
callsigns = {}
|
||||
config = None
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
if cls._instance is None:
|
||||
cls._instance = super().__new__(cls)
|
||||
cls._instance.lock = threading.Lock()
|
||||
cls.callsigns = {}
|
||||
return cls._instance
|
||||
|
||||
def update_seen(self, packet):
|
||||
callsign = None
|
||||
if "fromcall" in packet:
|
||||
callsign = packet["fromcall"]
|
||||
elif "from" in packet:
|
||||
callsign = packet["from"]
|
||||
if callsign not in self.callsigns:
|
||||
self.callsigns[callsign] = {
|
||||
"last": None,
|
||||
"count": 0,
|
||||
}
|
||||
self.callsigns[callsign]["last"] = str(datetime.datetime.now())
|
||||
self.callsigns[callsign]["count"] += 1
|
||||
|
||||
|
||||
def get_packet_type(packet):
|
||||
"""Decode the packet type from the packet."""
|
||||
|
||||
|
@ -201,6 +201,7 @@ class APRSDStats:
|
||||
}
|
||||
|
||||
wl = packets.WatchList()
|
||||
sl = packets.SeenList()
|
||||
|
||||
stats = {
|
||||
"aprsd": {
|
||||
@ -211,6 +212,7 @@ class APRSDStats:
|
||||
"memory_peak": self.memory_peak,
|
||||
"memory_peak_str": utils.human_size(self.memory_peak),
|
||||
"watch_list": wl.callsigns,
|
||||
"seen_list": sl.callsigns,
|
||||
},
|
||||
"aprs-is": {
|
||||
"server": self.aprsis_server,
|
||||
|
@ -58,11 +58,31 @@ function update_watchlist_from_packet(callsign, val) {
|
||||
//console.log(watchlist)
|
||||
}
|
||||
|
||||
function update_seenlist( data ) {
|
||||
var seendiv = $("#seenDiv");
|
||||
var html_str = '<table class="ui celled striped table">'
|
||||
html_str += '<thead><tr><th>HAM Callsign</th><th>Age since last seen by APRSD</th>'
|
||||
html_str += '<th>Number of packets RX</th></tr></thead><tbody>'
|
||||
seendiv.html('')
|
||||
var seen_list = data["stats"]["aprsd"]["seen_list"]
|
||||
var len = Object.keys(seen_list).length
|
||||
$('#seen_count').html(len)
|
||||
jQuery.each(seen_list, function(i, val) {
|
||||
html_str += '<tr><td class="collapsing">'
|
||||
html_str += '<img id="callsign_'+i+'" class="aprsd_1"></img>' + i + '</td>'
|
||||
html_str += '<td>' + val["last"] + '</td>'
|
||||
html_str += '<td>' + val["count"] + '</td></tr>'
|
||||
});
|
||||
html_str += "</tbody></table>";
|
||||
seendiv.append(html_str);
|
||||
}
|
||||
|
||||
function update_plugins( data ) {
|
||||
var plugindiv = $("#pluginDiv");
|
||||
var html_str = '<table class="ui celled striped table"><thead><tr>'
|
||||
html_str += '<th>Plugin Name</th><th>Plugin Enabled?</th>'
|
||||
html_str += '<th>Processed Packets</th><th>Sent Packets</th>'
|
||||
html_str += '<th>Version</th>'
|
||||
html_str += '</tr></thead><tbody>'
|
||||
plugindiv.html('')
|
||||
|
||||
@ -72,7 +92,9 @@ function update_plugins( data ) {
|
||||
for (var i=0; i<keys.length; i++) { // now lets iterate in sort order
|
||||
var key = keys[i];
|
||||
var val = plugins[key];
|
||||
html_str += '<tr><td class="collapsing">' + key + '</td><td>' + val["enabled"] + '</td><td>' + val["rx"] + '</td><td>' + val["tx"] + '</td></tr>';
|
||||
html_str += '<tr><td class="collapsing">' + key + '</td>';
|
||||
html_str += '<td>' + val["enabled"] + '</td><td>' + val["rx"] + '</td>';
|
||||
html_str += '<td>' + val["tx"] + '</td><td>' + val["version"] +'</td></tr>';
|
||||
}
|
||||
html_str += "</tbody></table>";
|
||||
plugindiv.append(html_str);
|
||||
@ -140,6 +162,7 @@ function start_update() {
|
||||
success: function(data) {
|
||||
update_stats(data);
|
||||
update_watchlist(data);
|
||||
update_seenlist(data);
|
||||
update_plugins(data);
|
||||
},
|
||||
complete: function() {
|
||||
|
@ -18,7 +18,6 @@
|
||||
<script src="/static/js/charts.js"></script>
|
||||
<script src="/static/js/tabs.js"></script>
|
||||
<script src="/static/js/send-message.js"></script>
|
||||
<script src="/static/js/packets.js"></script>
|
||||
<script src="/static/js/logs.js"></script>
|
||||
|
||||
|
||||
@ -79,6 +78,7 @@
|
||||
<div class="ui top attached tabular menu">
|
||||
<div class="active item" data-tab="charts-tab">Charts</div>
|
||||
<div class="item" data-tab="msgs-tab">Messages</div>
|
||||
<div class="item" data-tab="seen-tab">Seen List</div>
|
||||
<div class="item" data-tab="watch-tab">Watch List</div>
|
||||
<div class="item" data-tab="plugin-tab">Plugins</div>
|
||||
<div class="item" data-tab="config-tab">Config</div>
|
||||
@ -132,6 +132,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui bottom attached tab segment" data-tab="seen-tab">
|
||||
<h3 class="ui dividing header">
|
||||
Callsign Seen List (<span id="seen_count">{{ seen_count }}</span>)
|
||||
</h3>
|
||||
<div id="seenDiv" class="ui mini text">Loading</div>
|
||||
</div>
|
||||
|
||||
<div class="ui bottom attached tab segment" data-tab="watch-tab">
|
||||
<h3 class="ui dividing header">
|
||||
Callsign Watch List (<span id="watch_count">{{ watch_count }}</span>)
|
||||
|
Loading…
Reference in New Issue
Block a user