1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-11-23 08:28:39 -05:00

Compare commits

...

3 Commits

Author SHA1 Message Date
7dc0aee9e6 Added some changes to listen
to collect stats and only show those stats during listen
2024-10-31 19:30:31 -04:00
3fd606946d Fix a small issue with packet sending failures
When a packet _send_direct() failed to send due to a network
timeout or client issue, we don't want to count that as a send
attempt for the packet.  This patch catches that and allows for
another retry.
2024-10-31 18:10:46 -04:00
dependabot[bot]
fbfac97140 Bump werkzeug from 3.0.4 to 3.0.6
Bumps [werkzeug](https://github.com/pallets/werkzeug) from 3.0.4 to 3.0.6.
- [Release notes](https://github.com/pallets/werkzeug/releases)
- [Changelog](https://github.com/pallets/werkzeug/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/werkzeug/compare/3.0.4...3.0.6)

---
updated-dependencies:
- dependency-name: werkzeug
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-31 18:10:45 -04:00
5 changed files with 218 additions and 97 deletions

View File

@ -14,7 +14,10 @@ from aprsd.main import cli
os.environ["APRSD_ADMIN_COMMAND"] = "1" os.environ["APRSD_ADMIN_COMMAND"] = "1"
from aprsd import wsgi as aprsd_wsgi # this import has to happen AFTER we set the
# above environment variable, so that the code
# inside the wsgi.py has the value
from aprsd import wsgi as aprsd_wsgi # noqa
CONF = cfg.CONF CONF = cfg.CONF

View File

@ -135,14 +135,21 @@ class ListenStatsThread(APRSDThread):
if self.loop_count % 10 == 0: if self.loop_count % 10 == 0:
# log the stats every 10 seconds # log the stats every 10 seconds
stats_json = collector.Collector().collect() stats_json = collector.Collector().collect()
stats = stats_json["SimplePacketStats"] stats = stats_json["PacketList"]
total_rx = stats["total_rx"] total_rx = stats["rx"]
rate = (total_rx - self._last_total_rx) / 10 rate = (total_rx - self._last_total_rx) / 10
LOG.warning(f"RX Rate: {rate} pps Total RX: {total_rx} - {self._last_total_rx}") LOGU.opt(colors=True).info(
#LOG.error(stats) f"<green>RX Rate: {rate} pps</green> "
f"<yellow>Total RX: {total_rx}</yellow> "
f"<red>RX Last 10 secs: {total_rx - self._last_total_rx}</red>",
)
self._last_total_rx = total_rx self._last_total_rx = total_rx
for k, v in stats["types"].items(): for k, v in stats["types"].items():
LOGU.opt(colors=True).warning(f"Type: {k} <blue>RX: {v['rx']}</blue> <red>TX: {v['tx']}</red>") thread_hex = f"fg {utils.hex_from_name(k)}"
LOGU.opt(colors=True).info(
f"<{thread_hex}>{k:<15}</{thread_hex}> "
f"<blue>RX: {v['rx']}</blue> <red>TX: {v['tx']}</red>",
)
time.sleep(1) time.sleep(1)
return True return True
@ -261,26 +268,23 @@ def listen(
# just deregister the class from the packet collector # just deregister the class from the packet collector
packet_collector.PacketCollector().unregister(seen_list.SeenList) packet_collector.PacketCollector().unregister(seen_list.SeenList)
packet_collector.PacketCollector().register(SimplePacketStats) # from aprsd.client import stats as client_stats
# from aprsd.packets.packet_list import PacketList # noqa: F401
from aprsd.client import stats as client_stats # from aprsd.packets.seen_list import SeenList # noqa: F401
from aprsd.packets.packet_list import PacketList # noqa: F401 # from aprsd.packets.tracker import PacketTrack # noqa: F401
from aprsd.packets.seen_list import SeenList # noqa: F401 # from aprsd.packets.watch_list import WatchList # noqa: F401
from aprsd.packets.tracker import PacketTrack # noqa: F401 # from aprsd.plugins import email
from aprsd.packets.watch_list import WatchList # noqa: F401 # from aprsd.threads import aprsd as aprsd_thread
from aprsd.plugins import email # c = collector.Collector()
from aprsd.threads import aprsd as aprsd_thread # # c.unregister_producer(app.APRSDStats)
c = collector.Collector() # c.unregister_producer(PacketList)
# c.unregister_producer(app.APRSDStats) # c.unregister_producer(WatchList)
c.unregister_producer(PacketList) # #c.unregister_producer(PacketTrack)
c.unregister_producer(WatchList) # c.unregister_producer(plugin.PluginManager)
#c.unregister_producer(PacketTrack) # c.unregister_producer(aprsd_thread.APRSDThreadList)
c.unregister_producer(plugin.PluginManager) # c.unregister_producer(email.EmailStats)
c.unregister_producer(aprsd_thread.APRSDThreadList) # c.unregister_producer(client_stats.APRSClientStats)
c.unregister_producer(email.EmailStats) # c.unregister_producer(seen_list.SeenList)
c.unregister_producer(client_stats.APRSClientStats)
c.unregister_producer(seen_list.SeenList)
c.register_producer(SimplePacketStats)
pm = None pm = None
pm = plugin.PluginManager() pm = plugin.PluginManager()

View File

@ -89,6 +89,9 @@ def _send_direct(packet, aprs_client=None):
except Exception as e: except Exception as e:
LOG.error(f"Failed to send packet: {packet}") LOG.error(f"Failed to send packet: {packet}")
LOG.error(e) LOG.error(e)
return False
else:
return True
class SendPacketThread(aprsd_threads.APRSDThread): class SendPacketThread(aprsd_threads.APRSDThread):
@ -150,8 +153,17 @@ class SendPacketThread(aprsd_threads.APRSDThread):
# no attempt time, so lets send it, and start # no attempt time, so lets send it, and start
# tracking the time. # tracking the time.
packet.last_send_time = int(round(time.time())) packet.last_send_time = int(round(time.time()))
_send_direct(packet) sent = False
packet.send_count += 1 try:
sent = _send_direct(packet)
except Exception:
LOG.error(f"Failed to send packet: {packet}")
else:
# If an exception happens while sending
# we don't want this attempt to count
# against the packet
if sent:
packet.send_count += 1
time.sleep(1) time.sleep(1)
# Make sure we get called again. # Make sure we get called again.
@ -199,8 +211,18 @@ class SendAckThread(aprsd_threads.APRSDThread):
send_now = True send_now = True
if send_now: if send_now:
_send_direct(self.packet) sent = False
self.packet.send_count += 1 try:
sent = _send_direct(self.packet)
except Exception:
LOG.error(f"Failed to send packet: {self.packet}")
else:
# If an exception happens while sending
# we don't want this attempt to count
# against the packet
if sent:
self.packet.send_count += 1
self.packet.last_send_time = int(round(time.time())) self.packet.last_send_time = int(round(time.time()))
time.sleep(1) time.sleep(1)

View File

@ -269,7 +269,6 @@ def init_app(config_file=None, log_level=None):
return log_level return log_level
print(f"__name__ = {__name__}")
if __name__ == "__main__": if __name__ == "__main__":
async_mode = "threading" async_mode = "threading"

View File

@ -4,69 +4,162 @@
# #
# pip-compile --annotation-style=line requirements.in # pip-compile --annotation-style=line requirements.in
# #
aprslib==0.7.2 # via -r requirements.in aprslib==0.7.2
attrs==24.2.0 # via ax253, kiss3, rush # via -r requirements.in
ax253==0.1.5.post1 # via kiss3 attrs==24.2.0
beautifulsoup4==4.12.3 # via -r requirements.in # via
bidict==0.23.1 # via python-socketio # ax253
bitarray==3.0.0 # via ax253, kiss3 # kiss3
blinker==1.8.2 # via flask # rush
certifi==2024.8.30 # via requests ax253==0.1.5.post1
charset-normalizer==3.4.0 # via requests # via kiss3
click==8.1.7 # via -r requirements.in, click-params, flask beautifulsoup4==4.12.3
click-params==0.5.0 # via -r requirements.in # via -r requirements.in
commonmark==0.9.1 # via rich bidict==0.23.1
dataclasses==0.6 # via -r requirements.in # via python-socketio
dataclasses-json==0.6.7 # via -r requirements.in bitarray==3.0.0
debtcollector==3.0.0 # via oslo-config # via
deprecated==1.2.14 # via click-params # ax253
flask==3.0.3 # via -r requirements.in, flask-httpauth, flask-socketio # kiss3
flask-httpauth==4.8.0 # via -r requirements.in blinker==1.8.2
flask-socketio==5.4.1 # via -r requirements.in # via flask
geographiclib==2.0 # via geopy certifi==2024.8.30
geopy==2.4.1 # via -r requirements.in # via requests
h11==0.14.0 # via wsproto charset-normalizer==3.4.0
idna==3.10 # via requests # via requests
imapclient==3.0.1 # via -r requirements.in click==8.1.7
importlib-metadata==8.5.0 # via ax253, kiss3 # via
itsdangerous==2.2.0 # via flask # -r requirements.in
jinja2==3.1.4 # via flask # click-params
kiss3==8.0.0 # via -r requirements.in # flask
loguru==0.7.2 # via -r requirements.in click-params==0.5.0
markupsafe==3.0.2 # via jinja2, werkzeug # via -r requirements.in
marshmallow==3.23.0 # via dataclasses-json commonmark==0.9.1
mypy-extensions==1.0.0 # via typing-inspect # via rich
netaddr==1.3.0 # via oslo-config dataclasses==0.6
oslo-config==9.6.0 # via -r requirements.in # via -r requirements.in
oslo-i18n==6.4.0 # via oslo-config dataclasses-json==0.6.7
packaging==24.1 # via marshmallow # via -r requirements.in
pbr==6.1.0 # via oslo-i18n, stevedore debtcollector==3.0.0
pluggy==1.5.0 # via -r requirements.in # via oslo-config
pygments==2.18.0 # via rich deprecated==1.2.14
pyserial==3.5 # via pyserial-asyncio # via click-params
pyserial-asyncio==0.6 # via kiss3 flask==3.0.3
python-engineio==4.10.1 # via python-socketio # via
python-socketio==5.11.4 # via -r requirements.in, flask-socketio # -r requirements.in
pytz==2024.2 # via -r requirements.in # flask-httpauth
pyyaml==6.0.2 # via -r requirements.in, oslo-config # flask-socketio
requests==2.32.3 # via -r requirements.in, oslo-config, update-checker flask-httpauth==4.8.0
rfc3986==2.0.0 # via oslo-config # via -r requirements.in
rich==12.6.0 # via -r requirements.in flask-socketio==5.4.1
rush==2021.4.0 # via -r requirements.in # via -r requirements.in
shellingham==1.5.4 # via -r requirements.in geographiclib==2.0
simple-websocket==1.1.0 # via python-engineio # via geopy
six==1.16.0 # via -r requirements.in geopy==2.4.1
soupsieve==2.6 # via beautifulsoup4 # via -r requirements.in
stevedore==5.3.0 # via oslo-config h11==0.14.0
tabulate==0.9.0 # via -r requirements.in # via wsproto
thesmuggler==1.0.1 # via -r requirements.in idna==3.10
typing-extensions==4.12.2 # via typing-inspect # via requests
typing-inspect==0.9.0 # via dataclasses-json imapclient==3.0.1
tzlocal==5.2 # via -r requirements.in # via -r requirements.in
update-checker==0.18.0 # via -r requirements.in importlib-metadata==8.5.0
urllib3==2.2.3 # via requests # via
validators==0.22.0 # via click-params # ax253
werkzeug==3.0.4 # via flask # kiss3
wrapt==1.16.0 # via -r requirements.in, debtcollector, deprecated itsdangerous==2.2.0
wsproto==1.2.0 # via simple-websocket # via flask
zipp==3.20.2 # via importlib-metadata jinja2==3.1.4
# via flask
kiss3==8.0.0
# via -r requirements.in
loguru==0.7.2
# via -r requirements.in
markupsafe==3.0.2
# via
# jinja2
# werkzeug
marshmallow==3.23.0
# via dataclasses-json
mypy-extensions==1.0.0
# via typing-inspect
netaddr==1.3.0
# via oslo-config
oslo-config==9.6.0
# via -r requirements.in
oslo-i18n==6.4.0
# via oslo-config
packaging==24.1
# via marshmallow
pbr==6.1.0
# via
# oslo-i18n
# stevedore
pluggy==1.5.0
# via -r requirements.in
pygments==2.18.0
# via rich
pyserial==3.5
# via pyserial-asyncio
pyserial-asyncio==0.6
# via kiss3
python-engineio==4.10.1
# via python-socketio
python-socketio==5.11.4
# via
# -r requirements.in
# flask-socketio
pytz==2024.2
# via -r requirements.in
pyyaml==6.0.2
# via
# -r requirements.in
# oslo-config
requests==2.32.3
# via
# -r requirements.in
# oslo-config
# update-checker
rfc3986==2.0.0
# via oslo-config
rich==12.6.0
# via -r requirements.in
rush==2021.4.0
# via -r requirements.in
shellingham==1.5.4
# via -r requirements.in
simple-websocket==1.1.0
# via python-engineio
six==1.16.0
# via -r requirements.in
soupsieve==2.6
# via beautifulsoup4
stevedore==5.3.0
# via oslo-config
tabulate==0.9.0
# via -r requirements.in
thesmuggler==1.0.1
# via -r requirements.in
typing-extensions==4.12.2
# via typing-inspect
typing-inspect==0.9.0
# via dataclasses-json
tzlocal==5.2
# via -r requirements.in
update-checker==0.18.0
# via -r requirements.in
urllib3==2.2.3
# via requests
validators==0.22.0
# via click-params
werkzeug==3.0.6
# via flask
wrapt==1.16.0
# via
# -r requirements.in
# debtcollector
# deprecated
wsproto==1.2.0
# via simple-websocket
zipp==3.20.2
# via importlib-metadata