A real-time system monitoring application for Linux, built in C++. This project provides a terminal-based interface similar to htop that displays system information including CPU usage, memory utilization, and running processes.
- CPU Monitoring: Real-time CPU utilization percentage for overall system and individual cores
- Memory Tracking: Current memory usage displayed as percentage and visual progress bar
- Process Information: Top 10 processes sorted by resource usage, showing:
- Process ID (PID)
- User
- CPU percentage
- RAM usage (MB)
- Uptime
- Command
- System Information: OS name, kernel version, system uptime
- Process Statistics: Total and running process counts
- Auto-refresh: Updates every second for real-time monitoring
The project is organized into several key components:
- ProcessParser (
src/process_parser.cpp): Parses Linux/procfilesystem to extract system and process information - SysInfo (
src/sys_info.cpp): Aggregates and manages system-level statistics (CPU, memory, uptime) - Process (
src/process.cpp): Represents individual process with its attributes - ProcessContainer (
src/process_container.cpp): Manages collection of processes and refresh logic - ncurses Display (
src/main.cpp): Terminal UI rendering using ncurses library - Utilities (
src/util.cpp,src/format.cpp): Helper functions for formatting and file I/O
- Operating System: Linux (uses
/procfilesystem) - Compiler: C++17 compatible compiler (GCC 7+ or Clang 5+)
- Libraries:
- ncurses library for terminal UI
- CMake 2.6 or higher
On Ubuntu/Debian:
sudo apt install libncurses5-dev libncursesw5-devOn Fedora/RHEL:
sudo dnf install ncurses-develThis project uses CMake and Make for building.
make build- Compiles the source code and generates the executablemake format- Applies ClangFormat to style the source codemake debug- Compiles with debugging symbols enabledmake clean- Removes thebuild/directory and all build artifacts
- Clone the repository:
git clone <repository-url>
cd System-Monitor-Project- Build the project:
make build- Run the monitor:
./build/monitorThe application will launch in your terminal and begin displaying real-time system information.
The application reads system information from Linux /proc filesystem:
/proc/stat- CPU statistics/proc/meminfo- Memory usage/proc/uptime- System uptime/proc/version- Kernel version/proc/[pid]/stat- Process-specific CPU and timing data/proc/[pid]/status- Process memory and user information/proc/[pid]/cmdline- Process command line
CPU utilization is calculated by measuring the difference in active and idle time between successive reads of /proc/stat, using the formula:
CPU % = 100 * (active_diff / (active_diff + idle_diff))
The application monitors all running processes and displays the top 10 by resource usage. Each process is updated every refresh cycle to show current CPU and memory consumption.
.
├── CMakeLists.txt # CMake build configuration
├── Makefile # Make targets for build automation
├── README.md # This file
├── include/ # Header files
│ ├── constants.h
│ ├── format.h
│ ├── linux_parser.h
│ ├── ncurses_display.h
│ ├── process.h
│ ├── process_container.h
│ ├── process_parser.h
│ ├── processor.h
│ ├── sys_info.h
│ ├── system.h
│ └── util.h
└── src/ # Source files
├── format.cpp
├── linux_parser.cpp
├── main.cpp
├── ncurses_display.cpp
├── process.cpp
├── process_container.cpp
├── process_parser.cpp
├── processor.cpp
├── sys_info.cpp
├── system.cpp
└── util.cpp
This project is part of the C++ Bootcamp curriculum.
