Skip to main content

Python package to record activity from processes

Project description

Build Status Coverage Status

About

psrecord is a small utility that uses the psutil library to record the CPU and memory activity of a process. The package is still under development and is therefore experimental.

The code is released under a Simplified BSD License, which is given in the LICENSE file.

Requirements

  • Python 2.7 or 3.3 and higher

  • psutil 1.0 or later

  • matplotlib (optional, used for plotting)

Installation

To install, simply do:

pip install psrecord

To install with the optional plotting dependencies, do:

pip install psrecord[plot]

Usage

Basics

To record the CPU and memory activity of an existing process to a file (use sudo for a root process):

psrecord 1330 --log activity.txt

where 1330 is an example of a process ID which you can find with ps or top. You can also use psrecord to start up a process by specifying the command in quotes:

psrecord "hyperion model.rtin model.rtout" --log activity.txt

Plotting

To make a plot of the activity:

psrecord 1330 --plot plot.png

This will produce a plot such as:

https://github.com/astrofrog/psrecord/raw/master/screenshot.png

You can combine these options to write the activity to a file and make a plot at the same time:

psrecord 1330 --log activity.txt --plot plot.png

Duration and intervals

By default, the monitoring will continue until the process is stopped. You can also specify a maximum duration in seconds:

psrecord 1330 --log activity.txt --duration 10

Finally, the process is polled as often as possible by default, but it is possible to set the time between samples in seconds:

psrecord 1330 --log activity.txt --interval 2

Subprocesses

To include sub-processes in the CPU and memory stats, use:

psrecord 1330 --log activity.txt --include-children

Running tests

To run tests, you will need pytest. You can install it with:

pip install pytest

You can then run the tests with:

pytest psrecord

Reporting issues

Please report any issues in the issue tracker.

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

psrecord-1.3.dev0.tar.gz (60.4 kB view details)

Uploaded Source

Built Distribution

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

psrecord-1.3.dev0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file psrecord-1.3.dev0.tar.gz.

File metadata

  • Download URL: psrecord-1.3.dev0.tar.gz
  • Upload date:
  • Size: 60.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for psrecord-1.3.dev0.tar.gz
Algorithm Hash digest
SHA256 a06ea65363df537ce3a4ed5f33dd3de03766c1ba8f8122919104832c8aef12e1
MD5 b36c2cefa9cf33a22f281d57049454ca
BLAKE2b-256 549e5b8aaaa9c73d9f2e208a5f5ca16e0b0f07bdaa469b7cb75ed5d8955032a5

See more details on using hashes here.

File details

Details for the file psrecord-1.3.dev0-py3-none-any.whl.

File metadata

  • Download URL: psrecord-1.3.dev0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for psrecord-1.3.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 90e7385022529ead977a187d82e8acb7af4b87956fe01631b4e370a03aebe0fd
MD5 e181bf24c4835656bb94d3f20d3890ca
BLAKE2b-256 eb13e9f2d4599e8e264b4df31178d7a3f11074559f15c2c7fbdc99cf6dfa7a45

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