1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-12-24 10:50:35 -05:00

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 config = None
connected = False connected = False
server_string = None
def __new__(cls, *args, **kwargs): def __new__(cls, *args, **kwargs):
"""This magic turns this into a singleton.""" """This magic turns this into a singleton."""
@ -153,7 +154,15 @@ class Aprsdis(aprslib.IS):
self.logger.debug("Server: %s", test) 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 == "": if callsign == "":
raise LoginError("Server responded with empty callsign???") raise LoginError("Server responded with empty callsign???")

View File

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

View File

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