mirror of
https://github.com/pablorevilla-meshtastic/meshview.git
synced 2026-03-04 23:27:46 +01:00
Providing /stats to give us basic reporting on number of nodes and packets seen by the tool
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
env/*
|
||||
__pycache__/*
|
||||
packets.db
|
||||
/table_details.py
|
||||
|
||||
2
main.py
2
main.py
@@ -28,7 +28,7 @@ if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser('meshview')
|
||||
parser.add_argument('--bind', nargs='*', default=['*'])
|
||||
parser.add_argument('--acme-challenge')
|
||||
parser.add_argument('--port', default=8080, type=int)
|
||||
parser.add_argument('--port', default=8081, type=int)
|
||||
parser.add_argument('--tls-cert')
|
||||
|
||||
parser.add_argument('--mqtt-server', default='mqtt.bayme.sh')
|
||||
|
||||
@@ -12,6 +12,29 @@ from meshview.models import Packet, PacketSeen, Node, Traceroute
|
||||
from meshview import notify
|
||||
|
||||
|
||||
|
||||
# We count the total amount of packages
|
||||
async def get_total_packet_count():
|
||||
async with database.async_session() as session:
|
||||
q = select(func.count(Packet.id)) # Use SQLAlchemy's func to count packets
|
||||
result = await session.execute(q)
|
||||
return result.scalar() # Return the total count of packets
|
||||
|
||||
# We count the total amount of nodes
|
||||
async def get_total_node_count():
|
||||
async with database.async_session() as session:
|
||||
q = select(func.count(Node.id)) # Use SQLAlchemy's func to count nodes
|
||||
result = await session.execute(q)
|
||||
return result.scalar() # Return the total count of nodes
|
||||
|
||||
# We count the total amount of seen packets
|
||||
async def get_total_packet_seen_count():
|
||||
async with database.async_session() as session:
|
||||
q = select(func.count(PacketSeen.node_id)) # Use SQLAlchemy's func to count nodes
|
||||
result = await session.execute(q)
|
||||
return result.scalar() # Return the total count of seen packets
|
||||
|
||||
|
||||
async def process_envelope(topic, env):
|
||||
if not env.packet.id:
|
||||
return
|
||||
@@ -266,3 +289,6 @@ async def get_mqtt_neighbors(since):
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,19 +26,19 @@
|
||||
}
|
||||
#details_map {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
height: 500px;
|
||||
}
|
||||
{% block css %}
|
||||
{% endblock %}
|
||||
</style>
|
||||
</head>
|
||||
<body hx-indicator="#spinner">
|
||||
<div style="text-align:center"><strong>Bay Area Mesh - http://bayme.sh</strong></div>
|
||||
<div style="text-align:center"><a href="/">Search for a node </a> - <a href="/graph/network">See a realtime graph of the network </a> - <a href="/chat">See what people are saying </a> - <a href="/firehose">See <strong>everything</strong> </a> </div><br>
|
||||
<div id="spinner" class="spinner-border secondary-primary htmx-indicator position-absolute top-50 start-50" role="status">
|
||||
<br><div style="text-align:center"><strong>Bay Area Mesh - http://bayme.sh</strong></div>
|
||||
<div style="text-align:center">Quick Links: <a href="/">Search for a node </a> - <a href="/chat">Conversations</a> - <a href="/firehose">See <strong>everything</strong> </a> - <a href="/graph/network">Mesh Graph </a></div><br> <div id="spinner" class="spinner-border secondary-primary htmx-indicator position-absolute top-50 start-50" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
{% block body %}
|
||||
{% endblock %}
|
||||
<br><div style="text-align:center">Visit <strong><a href="https://github.com/pablorevilla-meshtastic/meshview">Meshview</a></strong> on Github. Also visit the original <a href="https://github.com/armooo/meshview">Meshview</a> by Armooo.</div><br>
|
||||
</body>
|
||||
</html>
|
||||
18
meshview/templates/stats.html
Normal file
18
meshview/templates/stats.html
Normal file
@@ -0,0 +1,18 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block css %}
|
||||
#packet_details{
|
||||
height: 95vh;
|
||||
overflow: scroll;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div style="font-family: Arial, sans-serif; color: #333; background-color: #f9f9f9; padding: 15px; border-radius: 8px; max-width: 300px; margin: auto;">
|
||||
<p style="font-size: 18px; font-weight: bold; margin-bottom: 10px;">Total Nodes: <span style="font-weight: normal; color: #007bff;">{{ total_nodes }}</span></p>
|
||||
<p style="font-size: 18px; font-weight: bold; margin-bottom: 10px;">Total Packets: <span style="font-weight: normal; color: #007bff;">{{ total_packets }}</span></p>
|
||||
<p style="font-size: 18px; font-weight: bold;">Total MQQT Reports: <span style="font-weight: normal; color: #007bff;">{{ total_packets_seen }}</span></p>
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock body %}
|
||||
1104
meshview/web.py
1104
meshview/web.py
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user