Code Monkey home page Code Monkey logo

strace-analyzer's Introduction

strace-analyzer

Analyzes strace output.

Table of Contents

Usage

Create logs:

strace -s 0 -ff -o cmd.strace cmd

Analyze logs, with xxx being the first process ID, the analysis will follow forked processes automatically:

strace-analyzer cmd.strace.xxx

Note: Only works with traces created with the usage example above. There is no support for logs that contain output of multiple process IDs and the timed output variants are supported neither. The above-mentioned strace command line yields the shortest output and allows tracing the forked processes without too much effort.

Analysis

At the moment, strace-analyzer only analyzes reads and writes to the file system:

$ strace -s0 -ff -o tar.strace tar czfv pkgs.tar.gz /var/cache/pacman/pkg/linux-*
/var/cache/pacman/pkg/linux-5.12.1.arch1-1-x86_64.pkg.tar.zst
/var/cache/pacman/pkg/linux-api-headers-5.10.13-1-any.pkg.tar.zst
/var/cache/pacman/pkg/linux-docs-5.12.1.arch1-1-x86_64.pkg.tar.zst
/var/cache/pacman/pkg/linux-firmware-20210426.fa0efef-1-any.pkg.tar.zst
/var/cache/pacman/pkg/linux-lts-5.10.34-1-x86_64.pkg.tar.zst

$ strace-analyzer tar.strace.10099
Reads Bytes  Bytes/Op File
9722  94.9M  10.0K    /var/cache/pacman/pkg/linux-5.12.1.arch1-1-x86_64.pkg.tar.zst
111   1.1M   10.0K    /var/cache/pacman/pkg/linux-api-headers-5.10.13-1-any.pkg.tar.zst
2244  21.9M  10.0K    /var/cache/pacman/pkg/linux-docs-5.12.1.arch1-1-x86_64.pkg.tar.zst
17124 167.2M 10.0K    /var/cache/pacman/pkg/linux-firmware-20210426.fa0efef-1-any.pkg.tar.zst
7642  74.6M  10.0K    /var/cache/pacman/pkg/linux-lts-5.10.34-1-x86_64.pkg.tar.zst

Writes Bytes  Bytes/Op File
23020  359.7M 16.0K    pkgs.tar.gz

Installation

Arch Linux

Install the strace-analyzer AUR package:

pacaur -S strace-analyzer

cargo install

cargo install strace-analyzer

from source

git clone https://github.com/wookietreiber/strace-analyzer.git
cd strace-analyzer
cargo build --release
install -Dm755 target/release/strace-analyzer ~/bin/strace-analyzer

strace-analyzer's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar wookietreiber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

strace-analyzer's Issues

join forces with lurk

Hi, I am currently doing a massive rewrite of lurk (@JakWai01 has been graciously merging my PRs). I think all three of us can join forces on these efforts, especially since @jasonwhite has created an awesome lib of all syscalls for lots of platforms.

Ideally we could either work under @JakWai01's repo, or set up a new org for this (takes a few min) -- this would ensure rapid iterations on the project. What do you think?

discussion: what to do with mmap?

What to do with mmap?

At the mmap syscall, the analysis essentially ends. There is no more information to be gained, because there are no follow up syscalls because mmap is not implemented in terms of read / write but the kernel actually does the rest, which we can't look into with strace.

  • Should we just ignore mmap?
  • Should we print to STDERR that file has been mmaped?

follow file descriptors beyond fork boundaries

observed case: star -c -f data.tar data:

star.strace.97073:1532348050.103783 open("data-star.tar", O_RDWR|O_CREAT, 0666) = 7 <0.000976>
star.strace.97073:1532348050.105748 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f6089f3ea70) = 97074 <0.000213>
star.strace.97074:1532348050.204140 write(7, "data/\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 10240)             = 10240 <0.000452>

error during execution sbt stage

[error] sbt.compiler.EvalException: Type error in expression
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?

other strace command line options

  • -y and -yy for filename and port:ip resolution - does this work across different log files?
  • -P path to limit to path in advance
  • modify suggestion / recommendation in README / man page accordingly

option to accumulate stats over different log files

In some cases it might make sense to accumulate the syscalls over multiple log files. The following is sort of a dummy example to showcase this:

$ strace -T -ttt -ff -o /tmp/strace-dd.log dd if=/dev/zero of=/dev/null count=1024 bs=1M
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.322192 s, 3.3 GB/s

$ strace -T -ttt -ff -o /tmp/strace-dd.log dd if=/dev/zero of=/dev/null count=1024 bs=1M
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.365162 s, 2.9 GB/s

$ ls -lh /tmp/strace-dd.log.*
-rw-r--r-- 1 wookietreiber users 261K Mar 26 11:08 /tmp/strace-dd.log.23687
-rw-r--r-- 1 wookietreiber users 261K Mar 26 11:08 /tmp/strace-dd.log.23694

$ strace-analyzer write /tmp/strace-dd.log.* | column -t 
write  1G   in  27.621  ms  (~  36G   /  s)  with  1024  ops  (~  1M  /  op,  ~  1M  request  size)  /dev/null
write  101  in  229     us  (~  431K  /  s)  with  3     ops  (~  34  /  op,  ~  34  request  size)  STDERR
write  1G   in  27.885  ms  (~  36G   /  s)  with  1024  ops  (~  1M  /  op,  ~  1M  request  size)  /dev/null
write  101  in  4.667   ms  (~  21K   /  s)  with  3     ops  (~  34  /  op,  ~  34  request  size)  STDERR

Also, if the stats are not accumulated over multiple files, the output should include from which log file they are.

error on install

error: failed to select a version for the requirement `bytesize = "^1"`
candidate versions found which didn't match: 1.1.0, 1.0.1, 1.0.0, ...
location searched: crates.io index
required by package `strace-analyzer v0.5.2 (/root/strace-analyzer)

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.