DEV Community

Md. Mahmudul Hasan Mabud
Md. Mahmudul Hasan Mabud

Posted on

From Curiosity to Code: How I Built SysLens, a Linux CLI System Monitor

Ever wondered what’s really happening inside your Linux system? The tools you use every day—top, htop, neofetch—give you the numbers, but do you know how they actually work under the hood?

I didn’t—so I decided to build my own. Enter SysLens: a lightweight, fast, and simple CLI system monitor written entirely in C.


Why Another System Monitor?

There are dozens of Linux tools already. Why make one more?

For me, it was all about learning by doing. Every new project is a skill test, and building something from scratch forces you to explore details you’d otherwise take for granted. With SysLens, I wanted to:

  1. Understand the Linux /proc filesystem deeply

  2. Parse and display system stats efficiently in C

  3. Learn to build a professional, modular CLI tool


Meet SysLens

SysLens gives you essential system information in a clean, readable format:

[ System Info ]
OS : Ubuntu 22.04 | Kernel : 6.8.0
CPU : Intel(R) Core(TM) i5
Uptime : 27 mins | User : mahmudul

[ Resource Usage ]
RAM : [###.......] 34% (2.7GiB/7.6GiB)
Swap : [..........] 0%
Load avg : 1.40, 1.17, 0.78

[ Active Processes ]
Task : 231 total | 2 running | 229 sleeping | 0 zombie

No clutter. No fluff. Just real-time, critical system info at a glance.


Core Features

System Overview: OS, Kernel, CPU, uptime, current user

Resource Monitoring: RAM, swap, load averages with color-coded bars

Process Stats: Total, running, sleeping, and zombie processes

CLI Flags: -s, -m, -p, --help, --version

Lightweight & Fast: Minimal memory footprint, no external dependencies


How SysLens Works

SysLens reads directly from Linux’s virtual /proc filesystem:

/proc/cpuinfo → CPU model

/proc/meminfo → RAM and swap usage

/proc/loadavg → system load averages

/proc/uptime → uptime

/proc/[PID]/status → process states

By parsing these files safely and efficiently, it outputs everything you need without unnecessary overhead.


Code Structure

I kept the code modular to maintain readability and scalability:

syslens/
├── include/main.h # Headers & macros
├── src/main.c # CLI & orchestrator
├── src/sys.c # OS & CPU info
├── src/mem.c # Memory & load logic
├── src/proc.c # Process parsing
├── Makefile
└── README.md

Every module handles a single responsibility—classic separation-of-concerns in action.


Lessons Learned

Building SysLens taught me more about Linux internals than I could have imagined:

How virtual filesystems expose kernel data

How to parse system stats safely and efficiently

How to design CLI tools with modular C code

The importance of readable, maintainable code

Most importantly:

The best way to learn a tool is to build it yourself.


Future Plans

Real-time CPU usage bars

Disk and network monitoring

Improved terminal UI

Automated builds and CI/CD pipeline for multi-platform releases


Try SysLens Yourself

GitHub: https://github.com/mahmudul626/syslens
Portfolio: https://mahmudul.pro.bd

Just clone, make, and run:

git clone https://github.com/mahmudul626/syslens.git
cd syslens
make
./syslens


Final Thoughts

SysLens started as a curiosity experiment, but now it’s a full-fledged CLI tool.

If you’re a Linux developer or C programmer, I challenge you to build one of the tools you use every day. It’s an incredible way to level up your skills and truly understand your system.

Top comments (0)