Added showing APRS-IS server to stats

This patch updates the client.py to collect which APRS-IS server
that aprsd is connected to and displays that info on the stats web page.
This commit is contained in:
Hemna 2021-03-30 10:43:31 -04:00
parent fb979eda94
commit d1a2a14370
3 changed files with 17 additions and 3 deletions

View File

@ -18,6 +18,7 @@ class Client:
config = None
connected = False
server_string = None
def __new__(cls, *args, **kwargs):
"""This magic turns this into a singleton."""
@ -153,7 +154,15 @@ class Aprsdis(aprslib.IS):
self.logger.debug("Server: %s", test)
_, _, callsign, status, _ = test.split(" ", 4)
a, b, callsign, status, e = test.split(" ", 4)
s = e.split(",")
if len(s):
server_string = s[0].replace("server ", "")
else:
server_string = e.replace("server ", "")
self.logger.info("Connected to {}".format(server_string))
self.server_string = server_string
if callsign == "":
raise LoginError("Server responded with empty callsign???")

View File

@ -4,7 +4,7 @@ import logging
import tracemalloc
import aprsd
from aprsd import messaging, plugin, stats
from aprsd import client, messaging, plugin, stats
import flask
import flask_classful
from flask_httpauth import HTTPBasicAuth
@ -75,9 +75,12 @@ class APRSDFlask(flask_classful.FlaskView):
track = messaging.MsgTrack()
now = datetime.datetime.now()
current, peak = tracemalloc.get_traced_memory()
cl = client.Client()
server_string = cl.client.server_string
result = {
"version": aprsd.__version__,
"aprsis_server": server_string,
"uptime": stats_obj.uptime,
"size_tracker": len(track),
"stats": stats_obj.stats(),

View File

@ -140,6 +140,7 @@
function update_stats( data ) {
$("#version").text( data["version"] );
$("#aprsis").text( "APRS-IS Server: " + data["aprsis_server"] );
$("#uptime").text( "uptime: " + data["uptime"] );
const html_pretty = Prism.highlight(JSON.stringify(data, null, '\t'), Prism.languages.json, 'json');
$("#jsonstats").html(html_pretty);
@ -240,7 +241,7 @@
#title {
font-size: 4em;
}
#uptime: {
#uptime, #arpsis: {
font-size: 4px;
}
@ -251,6 +252,7 @@
<body>
<header>
<div id="title">APRSD version <span id="version"></div></div>
<div id="aprsis"></div>
<div id="uptime"></div>
</header>