GithubHelp home page GithubHelp logo

mukovnin / psfiles Goto Github PK

View Code? Open in Web Editor NEW
39.0 1.0 0.0 475 KB

A CLI tool to monitor file system activity of a Linux process

License: MIT License

CMake 0.94% C++ 93.56% Roff 5.50%
filesystem process trace linux io monitoring-tool ptrace

psfiles's Introduction

What is this?

psfiles is a simple utility to view file system activity of Linux processes. Only regular (p)read(v), (p)write(v), open(at), close, rename(at), unlink(at) syscalls are traced. If the file has been memory mapped, this utility will NOT show the number of bytes read or written.

Features

  • start new process or attach to existing one and trace its file system activity
  • output results to standard output or save results to file
  • custom results sorting and filtering

System requirements

  • 64 bit architecture
  • Linux kernel >= 5.3
  • Glibc >= 2.31 or Musl >= 1.2.0

Options

  • [--output, -o]: path to output file. Default: stdout.
  • [--delay, -d]: interval (seconds) between file list updates. Default: 1.
  • [--sort, -s]: column name to sort by (append "-" to column name to sorting in descending order). Default: path.
  • [--filter, -f]: glob to filter file paths. Default: *.
  • --pid, -p: attach to existing process with specified pid.
  • --cmdline, -c: spawn new process with specified cmdline. Incompatible with --pid option. It should be the last option.

Columns

  • path - path to file,
  • wsize - write size in bytes,
  • rsize - read size in bytes,
  • wcount - (p)write(v) syscalls count,
  • rcount - (p)read(v) syscalls count,
  • ocount - open(at)/creat syscalls count,
  • ccount - close syscalls count,
  • spec - special file events indicator: memory map (m), rename (r), unlink (u),
  • lthread, laccess - thread id and time of the last system call listed above.

Usage examples

psfiles should be launched by a privileged user (CAP_SYS_PTRACE capability is required).

Start new process, sort descending by write size, output to file, update output every minute:

  • psfiles -d 60 -s wsize- -o output.txt -c emacs /home/user/cpp/main.cpp

Attach to existing process, sort by path, output to stdout, update output every second, filter files from user home directory:

  • psfiles -f "/home/user/*" -p $(pidof gedit)

Control

If --output option was not specified, keyboard control is available:

  • 0 - 9: sort by specified column (0 - path, 1 - wsize, etc)
  • s: toggle sorting order
  • n: show next page (scroll down)
  • p: show previous page (scroll up)
  • q: quit

Screencast

psfiles screencast

How to build?

If you are an Arch Linux user, there is AUR package.

psfiles's People

Contributors

mukovnin 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

Watchers

 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.