Skip to content

Commit 69a36d9

Browse files
authored
v2.1.16 (#44)
* groundwork for instance heartbeats * Update __main__.py * Update pyproject.toml * Update __main__.py * Update __main__.py * Update __main__.py * listener marking in db * class level max hops * min 5 -> 30 * migrate to uv * remove final poetry * Update README.md * remove submodule * node map working, but ugly * that'll do for now * don't traceroute everyone, just who I tell you to * Update __main__.py * v2.1.1 * model_validate packet * include bell icon for alerts to trigger t1000e notification sound * Update __main__.py * !l command to see links * Update __main__.py * v2.1.3 * fix !l * v2.1.4 * testing working again * v2.1.5 * rework of notification messages * v2.1.7 alert settings modifications and full implementation * Update listener_db.py * Update listener_db.py * warn -> info * Update __main__.py * ditch the api * Update README.md * Update README.md * reconnect attempts + warning * Update __main__.py * Update __main__.py * v2.1.9 increment reconnect * Update __main__.py * alert symbols * readability * v2.1.11 remove message history. not useful. * v2.1.12 notify upon new connection * Update __main__.py * notify using threads * v2.1.13 listeners can all speak in unison * Update __main__.py * v2.1.14 ignore text messages from other listener nodes * Update __main__.py * v2.1.15 now checking system usage stats * CPU interval -> None * Update utils.py * v2.1.16 bug fix for durations * info -> debug * remove some debug fluff * Update README.md * strip alert_context
1 parent 6933341 commit 69a36d9

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ uv sync
5454
| `ENABLE_DEBUG` | Sets the logger to debug mode if set to `True`. | `False` |
5555
| `POSTGRES_DB` | The name of the Postgres database. | `listener_db` |
5656
| `POSTGRES_PASSWORD` | The password of the user to connect to the database | No default defined |
57+
| `ENABLE_DEBUG` | Sets the default logging level to `debug` if set to `true` | `false` |
5758

5859
## Docker Compose
5960
This repo has a [Docker Compose](docker-compose.yml) file to faster deploys. You'll also want to modify the [environment secrets](secrets_example.env) for your specific use as well. For examples on various docker deployments, see the [Docker Compose Readme](docker-examples.md)

meshtastic_listener/__main__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def __sanitize_packet__(self, packet: dict) -> dict:
183183
response = {}
184184
for key in packet:
185185
if isinstance(packet[key], bytes) or key == 'raw':
186-
logging.debug(f'Dropping raw bytes from packet: {key}:{packet[key]}')
186+
continue
187187
elif isinstance(packet[key], dict):
188188
response[key] = self.__sanitize_packet__(packet[key])
189189
else:
@@ -399,7 +399,7 @@ def __check_node_health__(self) -> None:
399399
alert_context += f'High Memory Usage: {health_check_stats.systemResources.memoryUsagePercent}%\n'
400400

401401
if alert_context != '':
402-
self.__notify_admins__(f'Node: {self.interface.getLongName()}\n{alert_context}', priority=True)
402+
self.__notify_admins__(f'Node: {self.interface.getLongName()}\n{alert_context.strip()}', priority=True)
403403

404404
self.previous_health_check = health_check_stats
405405

@@ -427,7 +427,7 @@ def __handle_text_message__(self, packet: dict) -> None:
427427
logging.debug(f'Message received from another listener node {payload.fromId}. Ignoring to prevent loops.')
428428
return None
429429

430-
self.__print_packet_received__(logging.info, packet)
430+
self.__print_packet_received__(logging.debug, packet)
431431

432432
response = None
433433
if self.cmd_handler is not None:
@@ -558,7 +558,7 @@ def __handle_position__(self, packet: dict) -> None:
558558
altitude=position.get('altitude'),
559559
precision_bits=position.get('precisionBits')
560560
)
561-
logging.debug(f'Updated position for node {packet["from"]}: {self.db.get_node(packet["from"])}')
561+
logging.debug(f'Updated position for node {packet["from"]}')
562562
except ItemNotFound as e:
563563
logging.warning(e)
564564

meshtastic_listener/listener_db/listener_db.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def insert_node(self, node: NodeBase) -> None:
8181
)
8282
session.execute(stmt)
8383
session.commit()
84-
logger.debug(f'Inserted node into DB: {node.model_dump_json()}')
8584

8685
def mark_node_as_listener(self, node_id: int, version: str) -> None:
8786
with self.session() as session:
@@ -565,10 +564,12 @@ def return_traceroute_success_rate(self, from_id: int, lookback_ts: int = 0) ->
565564
if item.txTime is not None and item.rxTime is not None
566565
]
567566

567+
avg = durations[0] if len(durations) == 1 else mean(durations)
568+
568569
return TracerouteStatistics(
569570
total=len(items),
570571
successes=sum(1 for item in items if item.tracerouteDetails is not None),
571-
avgTraceDuration=round(mean(durations), 2) if durations else 0.0
572+
avgTraceDuration=round(avg, 2) if durations else 0.0
572573
)
573574

574575
def select_favorite_nodes(self) -> list[Node]:

meshtastic_listener/utils.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ def system_stats() -> SystemResources:
3535
"""
3636
Gather system resource usage statistics.
3737
"""
38-
cpu_usage = psutil.cpu_percent(interval=1)
39-
memory = psutil.virtual_memory()
40-
disk = psutil.disk_usage('/')
41-
42-
return SystemResources(
43-
cpuUsagePercent=round(cpu_usage, 1),
44-
memoryUsagePercent=round(memory.percent, 1),
45-
diskUsagePercent=round(disk.percent, 1)
38+
stats = SystemResources(
39+
cpuUsagePercent=round(psutil.cpu_percent(interval=None), 1),
40+
memoryUsagePercent=round(psutil.virtual_memory().percent, 1),
41+
diskUsagePercent=round(psutil.disk_usage('/').percent, 1)
4642
)
43+
logger.debug(f"System Resource Statistics: {stats.model_dump()}")
44+
return stats

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "meshtatic_listener"
3-
version = "2.1.15"
3+
version = "2.1.16"
44
description = "A server for connecting to a Meshtastic device and responding to commands."
55
authors = [{ name = "Michael Gillett", email = "51103663+migillett@users.noreply.github.com" }]
66
requires-python = ">=3.10,<3.14"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)