Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLI System Monitor (CLISM)

A lightweight, terminal-based system monitor inspired by htop and top. Built for the Operating Systems Lab at Bahria University, Islamabad.

Reads directly from the Linux /proc pseudo-filesystem — no psutil or external dependencies.

Authors

  • Abdul Moid
  • Qasim Abdul Qadeer

Features

  • CPU Usage — Real-time overall CPU utilization bar with percentage
  • Per-Core CPU — Toggle individual core bars (press c)
  • Memory & Swap — Visual bars showing RAM and Swap usage
  • Process List — Scrollable table: PID, USER, CPU%, MEM%, STATE, COMMAND
  • Sorting — Toggle between CPU%, Memory%, and PID sorting (s)
  • Timeline - Displays past processes at any given instance and resource usage
  • Kill Processes — SIGTERM (k) or SIGKILL (F9) on selected process
  • Color Coding — Green (Running), Blue (Sleeping), Red (Zombie), Yellow (Disk), Magenta (Stopped)
  • Load Average — 1, 5, and 15-minute load averages
  • Keyboard Navigation — Arrow keys, PgUp/PgDn, Home/End
  • Auto-Refresh — Configurable interval (default 1 second)

Requirements

  • Linux (required for /proc filesystem)
  • Python 3.6+ (no external packages needed — uses only stdlib: curses, os, time, pwd)

Usage

# Run with default 1-second refresh
python3 monitor.py

# Custom refresh interval
python3 monitor.py --interval 2.0
python3 monitor.py -i 0.5

Controls

Key Action
q / F10 Quit
k Kill selected process (SIGTERM)
F9 Force-kill selected process (SIGKILL)
p / c / m Sort by PID / CPU% / MEM%
r Reverse current sort direction
s Cycle sort mode
/ Search / filter by process name
Esc Clear active search filter
g Go to a specific PID
↑ ↓ Navigate process list
PgUp / PgDn Scroll process list by one page
Home / End Jump to very first / last process
d / Enter Open full process detail view
t Open resource timeline
l View kill log
c Toggle per-core CPU bars

In the timeline view:

Key Action
← / → Move back / forward by 1 second
PgUp / PgDn Jump back / forward by 10 seconds
0 Return to live (real-time) view
j Jump to a specific clock time (e.g. 14:30)
↑ ↓ Navigate the process snapshot list
/ Search / filter processes in snapshot
g Go to a specific PID in snapshot
Enter / d Open process detail at that snapshot

The │ cursor shows your selected moment on the graph.

Project Structure

**CLISM**/
├── public
│   └── images                  # Preview images
│       ├── 1.webp
│       ├── 2.webp
│       ├── 3.webp
│       ├── 4.webp
│       ├── 5.webp
│       └── 6.webp
├── src
│   ├── core
│   │   ├── timeline
│   │   │   ├── history.py      # Timeline handler
│   │   │   └── __init__.py
│   │   ├── cpu.py              # CPU stats reader
│   │   ├── __init__.py
│   │   ├── memory.py           # Memory statis reader
│   │   └── process.py          # Process list and details reader
│   ├── ui
│   │   ├── __init__.py
│   │   └── ui.py               # UI handler
│   ├── utils
│   │   ├── helpers.py          # Helper functions
│   │   └── __init__.py
│   └── __init__.py
├── monitor.py                  # Main entry point, event loop
└── README.md                   # This file

8 directories, 19 files

How It Works

CPU Usage

Reads /proc/stat at two points in time (1 second apart), calculates the delta of user, nice, system, idle, and iowait jiffies. CPU% = (total_delta - idle_delta) / total_delta × 100.

Memory Info

Parses /proc/meminfo for MemTotal, MemAvailable, Buffers, Cached, SwapTotal, SwapFree. Used memory = MemTotal - MemAvailable.

Process Listing

Iterates over /proc/[0-9]+/ directories, reads /proc/[pid]/stat for PID, command, state, CPU times, RSS; reads /proc/[pid]/status for UID and VmRSS. Per-process CPU% is calculated from utime + stime deltas between refresh cycles.

Process States

  • R — Running (Green)
  • S — Sleeping (Blue)
  • Z — Zombie (Red)
  • D — Disk Sleep / Uninterruptible (Yellow)
  • T — Stopped (Magenta)

OS Concepts Covered

Concept Implementation
Process Management Enumerate processes, read states, send signals
CPU Scheduling Calculate CPU time slices, user vs system time
Memory Management Parse allocation data, used/free/cached/buffered
File Systems Read /proc pseudo-filesystem as kernel interface
IPC Send signals (SIGTERM, SIGKILL) to processes
System Calls /proc exposes syscall-level information

Preview

Dashboard

TimelinePaused

References

About

A CLI system montior, with timeline snapshotsand extensive resource usage details.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages