Python tool for monitoring and visualizing a running processes usage
Project description
ProcSight
Monitor and visualize a single process' resource usage (CPU, memory, I/O, context switches, threads, descriptors) with easy CSV export and publication‑ready plots.
Built on psutil, pandas, matplotlib, seaborn, and pydantic. Runs on macOS, Linux, and Windows.
Features
- Track a running process by PID or by name (with interactive disambiguation)
- Sampling by fixed interval for a fixed duration, fixed number of samples, or continuously until Ctrl+C
- Two modes:
- Basic: CPU per‑core percent and memory RSS/VMS
- Extended: adds CPU breakdown, memory breakdown, I/O bytes, context switches, descriptors, threads, and process metadata
- Save plots to PNG/SVG/PDF with light/dark themes and configurable DPI
- Export measurements to CSV (includes an "avg" summary row)
- Clean programmatic API for integration in your own scripts/notebooks
Requirements
- Python 3.11+
- Poetry (for development/packaging)
- Platforms: macOS, Linux, Windows (feature availability depends on OS and permissions)
Key dependencies (installed via Poetry): psutil, pandas, matplotlib, seaborn, pydantic, loguru, schedule.
Installation (with Poetry)
# 1) Install Poetry if you don't have it
# macOS/Linux (official)
curl -sSL https://install.python-poetry.org | python3 -
# 2) Clone and install dependencies
git clone https://github.com/ErikDoytchinov/ProcSight.git
cd ProcSight
poetry install
If you prefer not to use Poetry, you can inspect pyproject.toml and install the listed dependencies with your own workflow.
Quick start
Identify a PID you want to monitor, then run:
poetry run python main.py --pid 12345 --samples 60 --save-plots ./plots --no-show
--samples 60collects exactly 60 samples--save-plots ./plotswrites plots to the given directory--no-showavoids opening GUI windows (useful in headless/CI)
You can also select by name (first match or interactive if multiple):
poetry run python main.py --name python --duration 30 --interval 0.5 --save-plots ./plots
Extended mode (richer metrics + multiple plots):
poetry run python main.py --pid 12345 \
--samples 120 --interval 0.5 \
--extended --save-plots ./plots_ext --format svg --dpi 144 --theme dark --no-show
CSV export (basic or extended):
poetry run python main.py --pid 12345 --samples 30 --out out.csv --no-show
Optional local workload generator
This repo includes a helper script to generate CPU/memory/I/O load in a single PID you can monitor:
chmod +x scripts/stress.sh
./scripts/stress.sh -d 60 -m 512 -i 128
# The script prints: PID=<pid>; use that value with --pid
CLI reference
All options (from procsight/cli/parser.py):
--pid <int>: PID of the process to monitor--name <str>: Process name to monitor (first matching process is used if--pidisn’t provided)--interval <float>: Sampling interval seconds (default: 1.0)--duration <int>: Run for N seconds (mutually exclusive with--samples). 0 means continuous until Ctrl+C--samples <int>: Collect exactly N samples (mutually exclusive with--duration). 0 defers to duration/continuous--out <path>: Path to CSV output file (optional)--save-plots <dir>: Directory to save plots (if omitted, plots are only shown unless--no-showis used)--format {png,svg,pdf}: Image format for saved plots (default: png)--dpi <int>: DPI for saved images (default: 144)--transparent(flag): Save figures with transparent background--no-show(flag): Do not display plots (useful in headless runs or CI)--extended(flag): Collect extended metrics (I/O, context switches, file descriptors, threads, meta)--theme {light,dark}: Plot theme (default: light)
Notes:
- You must provide either
--pidor--name. - If multiple processes match
--name, you’ll be prompted to select one.
Outputs
Plots
-
Basic mode saves up to two figures when
--save-plotsis provided:cpu_pid<PID>.<ext>— CPU per‑core utilization over timemem_pid<PID>.<ext>— Resident memory (RSS MB) over time
-
Extended mode saves a suite of figures to the directory you provide:
cpu_components.<ext>— user/system/total CPU breakdownmemory_breakdown.<ext>— stacked RSS/Shared/Data/Text memoryio_cumulative.<ext>— cumulative I/O read/write MBctx_switches.<ext>— voluntary/involuntary context switchesdescriptors_threads.<ext>— open files, file descriptors, threadsdistributions.<ext>— histograms/KDEs of key metricscorr_heatmap.<ext>— correlation heatmap across numeric metrics
Use --theme dark and --transparent for presentation‑friendly assets.
CSV (via --out <file>)
- Basic mode columns:
sample, cpu_percent, rss_mb, vms_mb - Extended mode columns (subset shown; depends on OS support):
sample, uptime_sec, status, cpu_percent, cpu_user, cpu_system, rss_mb, vms_mb, shared_mb, data_mb, text_mb, read_count, write_count, read_bytes, write_bytes, read_chars, write_chars, ctx_voluntary, ctx_involuntary, open_files, fds, threads, cpu_affinity
- An extra final
avgrow is appended with numeric averages (non-numeric columns are ignored).
Programmatic API
You can use ProcSight as a library in your own scripts:
from procsight.core.monitor import Monitor
from procsight.visualization.plot import plot_cpu_usage, plot_memory_usage, plot_from_extended
m = Monitor(pid=12345, interval=0.5)
# Basic tuples: List[Tuple[CpuUsage, MemoryUsage]]
basic = m.get_process_usage_by_interval(duration=10, samples=0, extended=False)
# Extended samples: List[ProcessSample]
extended = m.get_process_usage_by_interval(duration=10, samples=0, extended=True)
# Plotting
plot_cpu_usage(basic, m.sample_times, show=True)
plot_memory_usage(basic, m.sample_times, show=True)
plot_from_extended(extended, m.sample_times, out_dir="./plots", show=False)
CSV export helper:
from procsight.core.file_export import export_to_csv
export_to_csv(SimpleNamespace(extended=True, out="out.csv"), extended)
Development
- Lint/format: Ruff is included. Run:
poetry run ruff check . poetry run ruff format . # optional if you enable Ruff formatter
- Tests + coverage:
poetry run pytest # Coverage HTML report at htmlcov/index.html
Project layout uses procsight/ with modules under:
procsight/core— sampling, monitor, CSV exportprocsight/models— pydantic models for metricsprocsight/visualization— plotting and themesprocsight/cli— argument parsing
Packaging and publishing
This project is configured for Poetry packaging (pyproject.toml):
- Update the version in
[tool.poetry]when you cut a release - Build artifacts:
poetry build # dist/ contains .whl and .tar.gz
- Publish to PyPI (requires configured credentials):
poetry publish
The package name is procsight and the README (this file) is used for the project long description.
Troubleshooting
- psutil permissions: some metrics (e.g., open files, affinity) may require elevated permissions or are unavailable on certain platforms; the tool falls back gracefully.
- Headless environments: use
--no-showto suppress GUI popups and rely on--save-plots. - Name matching finds multiple processes: the CLI will list matches and prompt for a selection.
- macOS security dialogs: accessing process info may trigger system prompts; grant access if needed.
Acknowledgements
License
This project is licensed under the MIT License — see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file procsight-1.0.0.tar.gz.
File metadata
- Download URL: procsight-1.0.0.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb42ef76b4b0e91633caf324ae1aa6d5ae8c4b37629c0a71b1772e000a51bc98
|
|
| MD5 |
7cd15262c73ee7870d505a960e34cca4
|
|
| BLAKE2b-256 |
0e48af56cdd7dd58fc9e4dc14ac2432da59ee5ac921ca99e199d7d62e5b903ce
|
File details
Details for the file procsight-1.0.0-py3-none-any.whl.
File metadata
- Download URL: procsight-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f9c7742e9b0f2441a5a97bfa936579bdfb78515c81940774dc1e473f5a64fd3
|
|
| MD5 |
a66a8f147f2931d06d3d644578504667
|
|
| BLAKE2b-256 |
92d58eb48cd309ea8d97ef81943fa30f9f76df96e24c233e3a9c6e911db4af46
|