A network monitoring tool developed to track the status of network devices and analyze performance data in real-time.
A comprehensive network monitoring and analysis tool for Linux and macOS, similar to GlassWire or Little Snitch. Monitor real-time network traffic, identify bandwidth-consuming applications, and visualize your network activity with an elegant dashboard.
The dashboard provides real-time insights into your network activity:
tcpdump/libpcap on Linux for kernel-side BPF filtering,
lsof as a fallback for process lookuppip install . # core: capture + SQLite storage (scapy, psutil)
pip install '.[dashboard]' # + Streamlit dashboard (streamlit, pandas, numpy)
pip install '.[test]' # + pytest
The dashboard is optional: the core package imports and runs without streamlit.
The netmonitor .deb contains the core CLI and a systemd service that
captures without root (it only gets CAP_NET_RAW/CAP_NET_ADMIN):
sudo apt install ./netmonitor_0.1.0-1~ppa1_all.deb
sudo systemctl enable --now netmonitor # not started automatically
sudo usermod -aG netmonitor "$USER" # to read the captured data (re-login)
journalctl -u netmonitor -f
Choose the interface with sudo systemctl edit netmonitor:
[Service]
Environment=NETMONITOR_INTERFACE=wlp2s0
Streamlit is not in the Ubuntu archive, so the .deb does not include the dashboard. Install it into its own virtual environment:
sudo apt install python3-venv
python3 -m venv ~/.venvs/netmonitor-dashboard
~/.venvs/netmonitor-dashboard/bin/pip install \
'netmonitor[dashboard] @ git+https://github.com/Decuayer/NetMonitor@v0.1.0'
~/.venvs/netmonitor-dashboard/bin/netmonitor dashboard \
--db /var/lib/netmonitor/network_monitor.db
The venv is independent of the .deb; it only reads the database the service
writes (you must be in the netmonitor group).
sudo netmonitor run # or just: sudo netmonitor
sudo netmonitor run -i wlp2s0 # pick an interface explicitly
netmonitor dashboard # http://127.0.0.1:8501
netmonitor dashboard --port 9000 --address 0.0.0.0
netmonitor info # detected interface, database path, lsof availability
netmonitor --help
python3 -m netmonitor works the same way without the console script.
βββββββββββββββββββ
β Packet Sniffer β β Captures packets using scapy (auto-detected interface)
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Packet Processorβ β Enriches with process info, DNS, category
ββββββββββ¬βββββββββ
β
ββββββββββββββββ
βΌ βΌ
βββββββββββββββ ββββββββββββββββ
β Database β β Aggregator β β Real-time stats
β (SQLite) β β (In-Memory) β
βββββββββββββββ ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββ
β Dashboard β β Streamlit UI
β (Web Browser)β
ββββββββββββββββ
NetMonitor/
βββ pyproject.toml
βββ src/netmonitor/
β βββ cli.py # `netmonitor` entry point
β βββ monitor.py # Capture/processing orchestration
β βββ packet_sniffer.py # Packet capture using scapy
β βββ process_mapper.py # Maps ports to applications (psutil/lsof)
β βββ platform_support.py # Linux/macOS differences (interface, lsof, ...)
β βββ dns_resolver.py # DNS resolution and categorization
β βββ database.py # SQLite database operations
β βββ paths.py # Database location
β βββ data_aggregator.py # Real-time data aggregation
β βββ formatting.py # Shared display helpers
β βββ config.py # Configuration settings
β βββ dashboard/ # Optional Streamlit dashboard
β βββ __init__.py # launcher (does not import streamlit)
β βββ app.py # Streamlit app
βββ tests/ # pytest unit tests (no network/root needed)
| Setting | How to change |
|---|---|
| Interface | -i/--interface, $NETMONITOR_INTERFACE, or NETWORK_INTERFACE in config.py; default is the interface of the default route |
| Database | --db PATH or $NETMONITOR_DB |
| Categories, filter, cache sizes | src/netmonitor/config.py |
| Running as | Path |
|---|---|
| root | /var/lib/netmonitor/network_monitor.db |
| regular user | $XDG_DATA_HOME/netmonitor/network_monitor.db (default ~/.local/share/netmonitor/) |
A regular user who has no database of their own (e.g. running only the
dashboard) reads the system database written by sudo netmonitor run.
netmonitor info # shows the auto-detected interface
ip -br link # Linux: eth0, enp3s0, wlp2s0, lo ...
ifconfig # macOS: en0, en1, lo0 ...
The PacketSniffer uses scapy to capture network packets at the interface level. This needs root: on macOS to open the BPF devices, on Linux for raw (AF_PACKET) sockets. On Linux scapy compiles the tcp or udp filter with tcpdump/libpcap; if neither is installed, capture continues unfiltered and non-TCP/UDP packets are dropped in Python.
The ProcessMapper uses psutil and lsof to map network connections to specific processes:
psutil.net_connections(): Gets active connections with PIDs (reads /proc on Linux)lsof -i :PORT: Fallback when lsof is installedThe local end of each packet (source for outgoing, destination for incoming) is used for the lookup.
The DNSResolver performs reverse DNS lookups to convert IP addresses to hostnames and categorizes traffic based on domain keywords.
All captured traffic is stored in a SQLite database for historical analysis. The database includes indexes for efficient querying.
The Streamlit dashboard reads from both the in-memory aggregator (for live stats) and the database (for historical data), updating automatically every few seconds.
ERROR: Packet capture requires root privileges
Solution: sudo netmonitor run
Solution: check netmonitor info and ip -br link / ifconfig, then pass -i <iface>.
ip -br addr (Linux) / ifconfig en0 (macOS)sudo netmonitor run is runningpip install . # core
pip install '.[dashboard]' # dashboard
Edit src/netmonitor/config.py to add custom category keywords:
CATEGORY_KEYWORDS = {
"Streaming": ["youtube", "netflix", "twitch"],
"Custom Category": ["example.com", "myservice"],
# Add more categories...
}
Access the SQLite database directly:
sqlite3 ~/.local/share/netmonitor/network_monitor.db # or /var/lib/netmonitor/...
# Example queries
SELECT app_name, SUM(packet_size) as total FROM connections GROUP BY app_name;
SELECT category, COUNT(*) FROM connections GROUP BY category;
# Export to CSV
sqlite3 -header -csv /var/lib/netmonitor/network_monitor.db "SELECT * FROM connections;" > export.csv
Contributions are welcome! Areas for improvement:
MIT License - See LICENSE file for details
If you encounter issues:
netmonitor info for the detected interface and database pathpip install -e '.[test]'
pytest
Made with β€οΈ for network monitoring
π Happy Monitoring! π