A small Linux process and memory inspector that reads /proc directly
instead of shelling out to ps, top, or free. Includes a TCP
client/server pair so stats can be queried over the network.
Most beginner "system monitor" scripts just parse the output of
ps/free. This project skips that layer and reads the same files the
kernel exposes to those tools, to actually practice:
- Process lifecycle: reading process state, parent/child relationships,
and computing process uptime from
/proc/[pid]/stat'sstarttimefield and/proc/uptime. - Virtual memory: distinguishing
VmSize(virtual) fromVmRSS(resident/physical) per-process, and deriving used/free/cached from/proc/meminfo. - Sockets: a hand-written TCP server/client using Python's
socketmodule directly (no web framework), with a minimal line-delimited JSON protocol.
python3 cli.py mem # system-wide memory summary
python3 cli.py list # list all running processes
python3 cli.py process <pid> # detailed info for one processRunning python3 cli.py mem on linux terminal

Running python3 cli.py list on linux terminal
Start the server:
python3 server.py --host 0.0.0.0 --port 9000Query it from a client (same machine or another one):
python3 client.py --cmd mem --host <server-ip> --port 9000
python3 client.py --cmd process --pid 1234 --host <server-ip> --port 9000
python3 client.py --cmd list --host <server-ip> --port 9000| File | Purpose |
|---|---|
proc_reader.py |
Core parsing logic for /proc/[pid]/status, /proc/[pid]/stat, /proc/[pid]/cmdline, /proc/meminfo, /proc/uptime |
cli.py |
Local command-line interface built on proc_reader.py |
server.py |
TCP server exposing the same stats over a JSON-over-socket protocol |
client.py |
TCP client for querying the server |
No third-party dependencies -- everything uses the Python standard library
(os, socket, json, argparse).
- Some fields (e.g.
VmRSSfor zombie processes, or any field for processes owned by another user) may be empty or require elevated permissions to read -- this is standard Linux behavior, not a bug, and is handled gracefully (skipped rather than crashing). - The socket protocol is intentionally minimal (newline-delimited JSON, no auth/TLS) since the goal here is demonstrating socket programming fundamentals, not building a production monitoring service.