Skip to content

BaseMax/c-sysmon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c-sysmon

An interactive terminal-based system monitor for Linux, written in C using ncurses.

Features

  • Real-time System Monitoring

    • CPU usage with visual progress bar
    • Memory usage with visual progress bar
    • System load average (1, 5, and 15 minutes)
    • Live process list with detailed information
  • Process Management

    • Sortable process list (by PID, CPU, Memory, or Name)
    • Display process state, CPU%, memory%, and nice values
    • Scroll through process list with keyboard
  • User Interface

    • Clean ncurses-based terminal UI
    • Color-coded metrics (green/yellow/red based on usage)
    • Keyboard navigation and controls
    • Configurable refresh intervals

Architecture

The project follows a modular design with clear separation of concerns:

  • sysinfo.c/h: Data collection module - reads from /proc filesystem
  • ui.c/h: UI rendering module - handles ncurses display and user interaction
  • main.c: Main program - coordinates data collection and UI updates

Requirements

  • Linux operating system
  • GCC compiler
  • ncurses library

Installing ncurses

On Ubuntu/Debian:

sudo apt-get install libncurses5-dev libncursesw5-dev

On Fedora/RHEL/CentOS:

sudo dnf install ncurses-devel

On Arch Linux:

sudo pacman -S ncurses

Building

make

This will compile the source files and create the sysmon executable.

To clean build artifacts:

make clean

Installation

To install system-wide:

sudo make install

This installs the binary to /usr/local/bin/sysmon.

To uninstall:

sudo make uninstall

Usage

Run the system monitor:

./sysmon

Or if installed system-wide:

sysmon

Command Line Options

  • -h, --help: Display help message
  • -i, --interval SECONDS: Set refresh interval (default: 2 seconds)

Example with custom refresh interval:

./sysmon -i 5

Keyboard Controls

  • q: Quit the program
  • ↑/↓: Scroll through process list
  • PgUp/PgDn: Page up/down in process list
  • p: Sort by PID (ascending)
  • c: Sort by CPU usage (descending)
  • m: Sort by Memory usage (descending)
  • n: Sort by process Name (ascending)
  • r: Reverse current sort order

Display Information

Header Section

  • CPU: Current CPU usage percentage with visual bar
  • MEM: Memory usage percentage, visual bar, and used/total memory in MB
  • Load: System load average for 1, 5, and 15 minutes
  • Processes: Total number of running processes
  • Sort: Current sort mode and direction

Process List

Each process shows:

  • PID: Process ID
  • NAME: Process name (truncated to 25 characters)
  • STATE: Process state (R=Running, S=Sleeping, Z=Zombie, etc.)
  • CPU%: CPU usage percentage
  • MEM%: Memory usage percentage
  • MEM(KB): Memory usage in kilobytes
  • NICE: Process nice value (priority)

Technical Details

  • Reads CPU statistics from /proc/stat
  • Reads memory information from /proc/meminfo
  • Reads load average from /proc/loadavg
  • Reads process information from /proc/[pid]/stat and /proc/[pid]/status
  • Uses ncurses for terminal UI with color support
  • Implements efficient process sorting algorithms
  • Calculates CPU percentages based on time differences between samples

License

See LICENSE file for details.

About

An interactive terminal system monitor for CPU, memory, and processes. C, ncurses, /proc filesystem, Linux.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors