Skip to main content

followThePid is a Python library for tracing the CPU usage and energy consumption of a running process using its PID.

Project description

followThePid

followThePid is a Python library for tracing the CPU usage and energy consumption of a running process using its PID. It supports Linux and macOS (Intel and Apple Silicon).


Features

  • Trace CPU usage and energy per sampling interval
  • Option to normalize CPU usage per core (iris mode)
  • Uses Intel RAPL and powermetrics for energy measurements
  • Built-in support for saving data as:
    • CSV file
    • Pandas DataFrame

Requirements

  • Python 3.12+
  • One of:
    • Linux with Intel CPU and RAPL support
    • macOS with Intel CPU or Apple Silicon (M1/M2/M3)
  • sudo/root privileges

Installation

Recommended: Install from PyPI

The easiest way to install followThePid is directly from the PyPI:

pip install followthepid

Alternative: install from source

If you prefer to clone and work on the source code:

git clone https://github.com/se-fbk/followThePid.git
cd followThePid

python -m venv .venv
source .venv/bin/activate

pip install -e ".[test]"

RAPL Permissions

Linux (Intel CPUs)

By default, on recent kernels (≥ 5.10), access is restricted to root, as a security mitigation. To allow non-root reads:

# Example Package 0
sudo chmod o+r /sys/class/powercap/intel-rapl:0/energy_uj 

macOS (Intel and M-series)

Energy estimation rely on powermetrics APIs , sudo is needed.

Usage

import followThePid 
monitor = FollowThePid(
    cmd="python my_script.py",

)

# Start monitoring the process
monitor.monitor() 

# Summary
monitor.samples_csv()

Learn More

For detailed information on how followThePid works, supported architectures, and configuration examples,
see the 📘 Wiki.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

followthepid-0.1.2.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

followthepid-0.1.2-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file followthepid-0.1.2.tar.gz.

File metadata

  • Download URL: followthepid-0.1.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for followthepid-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7aade1e118b1d686eed84979015c790136a1df4a8983351309498d1fa2adb464
MD5 697895101172e18f3fec3a4cdcc83316
BLAKE2b-256 04b5cc131b668f5acde9bbe5a9473b97ad4016002570965bed165dcb920c6c87

See more details on using hashes here.

File details

Details for the file followthepid-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: followthepid-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for followthepid-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2dbd13f05b2a56d381f708ba6e65a2c203ade9d4cd452574650849fbc63d41c8
MD5 d8fc5804dd518a7a1f093ccdeb8624cd
BLAKE2b-256 b5f528308ea4b324faff846acb0ea5c358570713d892dea6f85e0c201042a594

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page