Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linux Process Monitor

A lightweight Linux Process Monitor written in C that demonstrates how modern operating systems expose process information through the /proc virtual filesystem.

The project reads process metadata directly from the Linux kernel, computes real-time CPU utilization, monitors memory usage, supports interactive sorting and filtering, and presents the information in a terminal-based user interface using ncurses.

Inspired by utilities such as top and ps, this project was implemented entirely from scratch for learning Operating Systems, Linux System Programming, and Process Management.


Features

Phase 1 – Process Enumeration

  • Enumerates all running processes from the /proc filesystem
  • Reads process information directly from /proc/[pid]/status
  • Displays:
    • Process ID (PID)
    • Process Name
    • Process State
    • Physical Memory Usage (VmRSS)
  • Handles processes that terminate during enumeration safely

Phase 2 – Real-Time Process Monitor

  • Real-time CPU utilization calculation
  • Live memory monitoring
  • Interactive terminal interface using ncurses
  • Refreshes every second
  • Sort processes by:
    • CPU Usage
    • Memory Usage
    • Process ID
  • Filter processes by name
  • Highlight high CPU usage processes
  • Responsive non-blocking keyboard controls

Demo

The animation below demonstrates the real-time monitoring interface, highlighting live process updates, interactive sorting capabilities, and terminal-based navigation.

Demonstrated sequence: Sort by CPU (c) → Sort by Memory (m) → Sort by PID (p) → Exit (q)

Linux Process Monitor Demo


How It Works

The monitor gathers information directly from the Linux kernel without relying on external utilities.

Process Information

Reads:

/proc/[pid]/status

to obtain:

  • Process Name
  • Process State
  • Resident Memory (VmRSS)

CPU Utilization

Reads:

/proc/[pid]/stat

to obtain:

  • User CPU Time
  • Kernel CPU Time

Reads:

/proc/stat

to obtain total CPU time.

CPU usage is computed by comparing two snapshots separated by one second.


Technologies Used

  • C
  • Linux
  • POSIX APIs
  • /proc Filesystem
  • ncurses
  • GCC

Linux Concepts Demonstrated

  • Process Management
  • Linux /proc Virtual Filesystem
  • System Calls
  • File I/O
  • Directory Traversal
  • Terminal User Interfaces (TUI)
  • CPU Scheduling Statistics
  • Memory Monitoring
  • Process Enumeration
  • Real-Time Monitoring

Project Structure

ProcessMonitor/
│
├── phase1.c          # Process enumeration
├── phase2.c          # Real-time process monitor
├── README.md
├── LICENSE
└── .gitignore

Building

Phase 1

gcc phase1.c -o phase1

Phase 2

gcc phase2.c -o phase2 -lncurses

Running

Phase 1

./phase1

Phase 2

./phase2

Filter by process name:

./phase2 chrome

Keyboard Controls

Key Action
c Sort by CPU Usage
m Sort by Memory Usage
p Sort by PID
q Quit

Sample Output

PID      NAME                 STATE    CPU%    MEMORY(KB)

2312     chrome               S        21.4      218432
1821     gnome-shell          S         8.6      174020
1120     systemd              S         0.2       14384
...

Skills Demonstrated

  • Linux System Programming
  • Operating Systems
  • Process Management
  • Terminal UI Development
  • Parsing Kernel Data Structures
  • File Handling
  • Data Structures
  • Sorting Algorithms
  • Real-Time System Monitoring
  • C Programming

Future Improvements

  • Multi-core CPU utilization
  • Process tree visualization
  • Thread information
  • Network connection monitoring
  • Per-process disk I/O statistics
  • Search inside the interface
  • Interactive process termination
  • Export statistics to CSV
  • Color themes
  • Historical CPU graphs

Learning Outcomes

This project was built to gain practical experience with:

  • Linux process management
  • Operating System internals
  • The /proc virtual filesystem
  • CPU usage calculation
  • Memory monitoring
  • Real-time terminal applications
  • Linux system programming in C

License

This project is licensed under the MIT License.


Author

Teja Sai Eswar

B.Tech, Department of Electronics and Electrical Communication Engineering

Indian Institute of Technology Kharagpur

About

Real-time process monitor in C using /proc and ncurses

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages