File: README.rst

package info (click to toggle)
psrecord 1.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 180 kB
  • sloc: python: 295; makefile: 7
file content (119 lines) | stat: -rw-r--r-- 2,716 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|Build Status| |Coverage Status|

About
=====

``psrecord`` is a small utility that uses the
`psutil <https://github.com/giampaolo/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 <https://code.google.com/p/psutil/>`__ 1.0 or later
-  `matplotlib <http://www.matplotlib.org>`__ (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:

.. image:: 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 <https://docs.pytest.org/en/latest/>`_. 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 <https://github.com/astrofrog/psrecord/issues>`__.

.. |Build Status| image:: https://travis-ci.org/astrofrog/psrecord.svg?branch=master
   :target: https://travis-ci.org/astrofrog/psrecord
.. |Coverage Status| image:: https://codecov.io/gh/astrofrog/psrecord/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/astrofrog/psrecord