Giter VIP home page Giter VIP logo

pystrace's Introduction

  pystrace -- Python tools for parsing and analysing strace output files
==========================================================================

Copyright 2012
    The President and Fellows of Harvard College.

Contributor(s):
    Peter Macko <pmacko at eecs.harvard.edu>


 Introduction
--------------

pystrace is a simple Python library and a small collection of tools for parsing
and analyzing the output of strace:
  
  strace.py -- the Python library
  strace2csv.py -- a tool to convert strace output to an easy-to-parse csv
  strace_systime_analyzer.py -- analyzes time spent in system calls

This project is an early stage, but unfortunately I do not currently have
resources to work on it. Nonetheless I hope that you would find it useful.
If you have any questions or if you would like to contribute, please just drop
me an email!


 Usage
-------

pystrace currently expects the analyzed file to contain timestamps in the "ttt"
format. For example, if you would like to analyze the strace of "ls", do the
following:

  strace -ttt -o ls.out ls

This generates ls.out, which you can read using class strace.StraceFile in your
Python programs or using one of the provided tools.

To take advantage of the full potential of pystrace, specify also the -T option
to measure the time spent in system calls and -f to follow the child processes:

  strace -f -ttt -T -o ls-full.out ls


 Using the Library: strace.py
------------------------------

You can use the library to either read a strace output file line by line using
strace.StraceInputStream or to load it in its entirety using strace.StraceFile.

StraceInputStream is an iterator that returns StraceEntry for each line in the
file. Please refer to strace2csv.py for an example.

StraceEntry contains the following fields:
  pid (if available)
  timestamp
  was_unfinished (True if the line ends with "<unfinished ...>")
  elapsed_time (if available)
  syscall_name
  syscall_arguments
  return_value
  category (currently "IO" for I/O system calls, "" for everything else)

StraceFile loads the given strace output file in its entirety. It contains the
following fields:
  input
  have_pids (True if each line in the input file is prefixed with a PID)
  content (an array of StraceEntry elements)
  processes (a dictionary mapping PIDs to StraceTracedProcess)
  start_time (the first timestamp)
  last_timestamp
  finish_time
  elapsed_time

StraceTracedProcess contains:
  pid
  name (the name of the process, if available)
  entries (an array of StraceEntry elements)

Please refer to strace_systime_analyzer.py for an example of how to use
StraceFile.


 Using strace2csv.py
---------------------

This tool converts a strace output file to a .csv file. For example:

  $ python strace2csv.py ls-full.out 
  PID,TIMESTAMP,SYSCALL,CATEGORY,SPLIT,ARGC,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,RESULT,ELAPSED
  2621,1388459393.107463,"execve",,0,3,"""/bin/ls""","[""ls""]","[/* 69 vars */]",,,,0,0.000138
  2621,1388459393.107761,"brk",,0,1,"0",,,,,,"0x2576000",0.000008
  2621,1388459393.107812,"access","IO",0,2,"""/etc/ld.so.nohwcap""","F_OK",,,,,"-1",0.000010
  2621,1388459393.107869,"mmap","IO",0,6,"NULL","8192","PROT_READ|PROT_WRITE","MAP_PRIVATE|MAP_ANONYMOUS","-1","0","0x7fbc0a2d2000",0.000009

You can use the -o argument to redirect the output to a file instead of the
standard output.


 Using strace_systime_analyzer.py
----------------------------------

This tool produces a .csv file that shows how much time the given process and
its children spent inside the system calls. The first column is a time in 0.1
second increments. The other columns correspond to the different PIDs contained
in the strace output. Each entry in these columns is the fraction of time spent
inside the system calls, where 0 means none and 1 means 100%.

pystrace's People

Stargazers

Abdullah Al Raqibul Islam avatar fen avatar

pystrace's Issues

[GSOC 2014] structured output of strace

Hi,
 I'm yangmin zhu. I'm a master student from University of Chinese Academy of Sciences and now I'm participating in the Google Summer of Code 2014.
 I'm working for the strace project about structured output. You can find more information from [1] and [2].
 I think it would be great to contact the strace output parser's author to collect their actual needs. I'm trying to modify strace to support output in JSON format. But I'm not very clear what the exact format you want.
  For examole,
1) should all the value in the JSON output be string? or some value should be 
number?
2) which of the followling style of syscall's arguments do you prefer?
  "args" : ["arg1", "arg2", "arg3" ] 
or
  "arg1" : [ "arg1_name" : "arg1_value", "arg2_name" : "arg2_value" }

ANY suggestion are welcome.

Thank you.
yangmin zhu

[1] http://sourceforge.net/p/strace/wiki/GoogleSummerOfCode2014/
[2] http://sourceforge.net/p/strace/mailman/message/31924683/

Original issue reported on code.google.com by [email protected] on 20 Mar 2014 at 5:37

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.