← udacity portfolio
cpp nd · systems cpp · January 2020

Linux System Monitor (htop clone)

Parse /proc to build an htop-style live process viewer in C++17 with ncurses. The C++ nanodegree's intro to Linux internals.

What it did

Build a terminal process monitor (like htop) from scratch in C++. Reads /proc/stat, /proc/meminfo, /proc/[pid]/* continuously, renders aggregate CPU%, memory, uptime, and a sortable per-process table via ncurses.

The /proc API surface

FileWhat
/proc/stataggregate CPU jiffies (user, nice, system, idle, iowait)
/proc/meminfoRAM total/free/cached/buffers
/proc/uptimeseconds since boot
/proc/[pid]/statper-process CPU jiffies + state + start-time
/proc/[pid]/statusper-process memory usage (RSS, VmSize)
/proc/[pid]/cmdlinethe full command line as a null-separated string
/proc/[pid]/commthe short command name

CPU% per process is (process_jiffies_now - process_jiffies_then) / (total_cpu_jiffies_now - total_cpu_jiffies_then) — a delta over a fixed sampling interval, never absolute.

What was actually tricky

What I’d do differently with hindsight

What it taught me

The Linux kernel exposes a lot through /proc and /sys — everything htop, ps, top, free, and uptime shows comes from parsing these. Knowing the schema makes you faster at debugging production issues; you can read /proc by hand instead of running a tool. That’s been useful many times since.


Source archive: Shivam-Bhardwaj/system-monitor-linux-cpp (archived)
Writeup last touched: 2026-05-22