一,工具简介
btrfsslower
显示慢于阈值的 btrfs 读取、写入、打开和同步操作
二,代码示例
#!/usr/bin/env pythonfrom __future__ import print_function
from bcc import BPF
import argparse
from datetime import datetime, timedelta
from time import strftime# symbols
kallsyms = "/proc/kallsyms"# arguments
examples = """examples:./btrfsslower # trace operations slower than 10 ms (default)./btrfsslower 1 # trace operations slower than 1 ms./btrfsslower -j 1 # ... 1 ms, parsable output (csv)./btrfsslower 0 # trace all operations (warning: verbose)./btrfsslower -p 185 # trace PID 185 only./btrfsslower -d 10 # trace for 10 seconds only
"""
parser = argparse.ArgumentParser(description="Trace common btrfs file operations slower than a threshold",formatter_class=argparse.RawDescriptionHelpFormatter,epilog=exa