diff --git a/aprsd/flask.py b/aprsd/flask.py index 7577425..63014c9 100644 --- a/aprsd/flask.py +++ b/aprsd/flask.py @@ -61,6 +61,10 @@ class APRSDFlask(flask_classful.FlaskView): watch_count = 0 watch_age = 0 + pm = plugin.PluginManager() + plugins = pm.get_plugins() + plugin_count = len(plugins) + return flask.render_template( "index.html", initial_stats=stats, @@ -69,6 +73,7 @@ class APRSDFlask(flask_classful.FlaskView): config_json=json.dumps(self.config), watch_count=watch_count, watch_age=watch_age, + plugin_count=plugin_count, ) @auth.login_required diff --git a/aprsd/plugin.py b/aprsd/plugin.py index 56b8fd7..14601c2 100644 --- a/aprsd/plugin.py +++ b/aprsd/plugin.py @@ -48,7 +48,8 @@ class APRSDPluginBase(metaclass=abc.ABCMeta): """The base class for all APRSD Plugins.""" config = None - message_counter = 0 + rx_count = 0 + tx_count = 0 version = "1.0" # Holds the list of APRSDThreads that the plugin creates @@ -103,6 +104,12 @@ class APRSDPluginBase(metaclass=abc.ABCMeta): """Gives the plugin writer the ability start a background thread.""" return [] + def rx_inc(self): + self.rx_count += 1 + + def tx_inc(self): + self.tx_count += 1 + def stop_threads(self): """Stop any threads this plugin might have created.""" for thread in self.threads: @@ -137,7 +144,10 @@ class APRSDWatchListPluginBase(APRSDPluginBase, metaclass=abc.ABCMeta): result = messaging.NULL_MESSAGE if wl.callsign_in_watchlist(packet["from"]): # packet is from a callsign in the watch list + self.rx_inc() result = self.process() + if result: + self.tx_inc() wl.update_seen(packet) return result @@ -185,8 +195,10 @@ class APRSDRegexCommandPluginBase(APRSDPluginBase, metaclass=abc.ABCMeta): and message ): if re.search(self.command_regex, message): - self.message_counter += 1 + self.rx_inc() result = self.process(packet) + if result: + self.tx_inc() <<<<<<< HEAD To reply with a message over the air, return a string diff --git a/aprsd/stats.py b/aprsd/stats.py index 4153ea9..144c6bf 100644 --- a/aprsd/stats.py +++ b/aprsd/stats.py @@ -193,7 +193,10 @@ class APRSDStats: ) for p in plugins: - plugin_stats[full_name_with_qualname(p)] = p.message_count + plugin_stats[full_name_with_qualname(p)] = { + "rx": p.rx_count, + "tx": p.tx_count, + } wl = packets.WatchList() diff --git a/aprsd/web/static/js/main.js b/aprsd/web/static/js/main.js index 9d3f930..f3849b3 100644 --- a/aprsd/web/static/js/main.js +++ b/aprsd/web/static/js/main.js @@ -58,6 +58,23 @@ function update_watchlist_from_packet(callsign, val) { //console.log(watchlist) } +function update_plugins( data ) { + var plugindiv = $("#pluginDiv"); + var html_str = '' + plugindiv.html('') + + var plugins = data["stats"]["plugins"]; + var keys = Object.keys(plugins); + keys.sort(); + for (var i=0; i'; + } + html_str += "
Plugin NameProcessed PacketsSent Packets
' + val["rx"] + '' + val["tx"] + '
"; + plugindiv.append(html_str); +} + function update_packets( data ) { var packetsdiv = $("#packetsDiv"); //nuke the contents first, then add to it. @@ -120,6 +137,7 @@ function start_update() { success: function(data) { update_stats(data); update_watchlist(data); + update_plugins(data); }, complete: function() { setTimeout(statsworker, 10000); diff --git a/aprsd/web/templates/index.html b/aprsd/web/templates/index.html index 082f5a6..5314a1c 100644 --- a/aprsd/web/templates/index.html +++ b/aprsd/web/templates/index.html @@ -71,6 +71,7 @@
Charts
Messages
Watch List
+
Plugins
Config
Raw JSON
@@ -129,6 +130,13 @@
Loading
+
+

+ Plugins Loaded ({{ plugin_count }}) +

+
Loading
+
+

Config

{{ config_json|safe }}