Skip to content

Commit

Permalink
Reworked the admin graphs
Browse files Browse the repository at this point in the history
This patch fixes some bugs wth the rpc for packets as well
as reworks the admin graphs to use echarts.
  • Loading branch information
hemna committed Nov 17, 2023
1 parent def0e81 commit f1c38be
Show file tree
Hide file tree
Showing 7 changed files with 499 additions and 23 deletions.
4 changes: 3 additions & 1 deletion aprsd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def main():
# First import all the possible commands for the CLI
# The commands themselves live in the cmds directory
from .cmds import ( # noqa
completion, dev, fetch_stats, healthcheck, list_plugins, listen,
completion, config, dev, fetch_stats, healthcheck, list_plugins, listen,
send_message, server, webchat,
)
cli(auto_envvar_prefix="APRSD")
Expand Down Expand Up @@ -145,6 +145,8 @@ def get_namespaces():
if not sys.argv[1:]:
raise SystemExit
raise
LOG.warning(conf.namespace)
return
generator.generate(conf)


Expand Down
2 changes: 2 additions & 0 deletions aprsd/packets/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class Packet(metaclass=abc.ABCMeta):
# hash=False
#)
last_send_time: float = field(repr=False, default=0, compare=False, hash=False)
last_send_attempt: int = field(repr=False, default=0, compare=False, hash=False)

# Do we allow this packet to be saved to send later?
allow_delay: bool = field(repr=False, default=True, compare=False, hash=False)
path: List[str] = field(default_factory=list, compare=False, hash=False)
Expand Down
15 changes: 14 additions & 1 deletion aprsd/packets/packet_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ class PacketList(MutableMapping):
lock = threading.Lock()
_total_rx: int = 0
_total_tx: int = 0
types = {}

def __new__(cls, *args, **kwargs):
if cls._instance is None:
cls._instance = super().__new__(cls)
cls._maxlen = 1000
cls._maxlen = 100
cls.d = OrderedDict()
return cls._instance

Expand All @@ -32,6 +33,10 @@ def rx(self, packet):
"""Add a packet that was received."""
self._total_rx += 1
self._add(packet)
ptype = packet.__class__.__name__
if not ptype in self.types:
self.types[ptype] = {"tx": 0, "rx": 0}
self.types[ptype]["rx"] += 1
seen_list.SeenList().update_seen(packet)
stats.APRSDStats().rx(packet)

Expand All @@ -40,6 +45,10 @@ def tx(self, packet):
"""Add a packet that was received."""
self._total_tx += 1
self._add(packet)
ptype = packet.__class__.__name__
if not ptype in self.types:
self.types[ptype] = {"tx": 0, "rx": 0}
self.types[ptype]["tx"] += 1
seen_list.SeenList().update_seen(packet)
stats.APRSDStats().tx(packet)

Expand All @@ -50,6 +59,10 @@ def add(self, packet):
def _add(self, packet):
self[packet.key] = packet

def copy(self):
return self.d.copy()


@property
def maxlen(self):
return self._maxlen
Expand Down
3 changes: 2 additions & 1 deletion aprsd/packets/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __len__(self):
@wrapt.synchronized(lock)
def add(self, packet):
key = packet.msgNo
packet._last_send_attempt = 0
self.data[key] = packet
self.total_tracked += 1

Expand All @@ -83,7 +84,7 @@ def restart(self):
"""Walk the list of messages and restart them if any."""
for key in self.data.keys():
pkt = self.data[key]
if pkt.last_send_attempt < pkt.retry_count:
if pkt._last_send_attempt < pkt.retry_count:
tx.send(pkt)

def _resend(self, packet):
Expand Down
Loading

0 comments on commit f1c38be

Please sign in to comment.