Git Product home page Git Product logo

psrecord's Introduction

Build Status Coverage Status

Update

Enhanced to support recording more metrics including:

  • net connections
  • io read/write bytes
  • open fds
  • threads

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

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.

psrecord's People

Contributors

astrofrog avatar saimn avatar willgittoes-dd avatar ghostsystem avatar ledzep2 avatar souravsingh avatar taldcroft avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.