Skip to content

google/libtracecmd-rs

libtracecmd-rs

A Rust wrapper of libtracecmd.

crates.io build status

This library is a Rust wrapper of libtracecmd, which allows writing programs to analyze Linux's ftrace data recoreded by trace-cmd.

Requirements

To use this crate in your program, you need to install the libtracecmd library (>= 1.2.0) on your system.

Example Usage

Let's see how it works with examples/top_n_events, which counts how many times each event occurred in a particular period.

First, create trace.dat by running trace-cmd.

trace-cmd record -e syscalls sleep 10

Then, show the top-10 syscall events in the trace.dat file.

cargo run --example top_n_events -- --input trace.dat --n 10 --prefix sys_enter_

Example output:

Top 10 events:
#1: ioctl: 62424 times
#2: futex: 59074 times
#3: read: 30144 times
#4: write: 28361 times
#5: newfstatat: 22590 times
#6: close: 15893 times
#7: splice: 14650 times
#8: getuid: 13579 times
#9: epoll_pwait: 12298 times
#10: ppoll: 10523 times

Contributing

See CONTRIBUTING.md for details.

License

Apache 2.0; see LICENSE for details.

Disclaimer

This project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose.