一,工具简介
dcsnoop工具用于追踪目录项缓存(dcache)的查找,并可用于 dcstat(8) 之外的进一步调查。由于 dcache 查找可能很频繁,因此输出可能很冗长。默认情况下,仅显示查找失败的情况。
二,代码示例
#!/usr/bin/env python
from __future__ import print_function
from bcc import BPF
import argparse
import re
import time
# arguments
examples = """examples:
./dcsnoop # trace failed dcache lookups
./dcsnoop -a # trace all dcache lookups
"""
parser = argparse.ArgumentParser(
description="Trace directory entry cache (dcache) lookups",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=examples)
parser.add_argument("-a", "--all", action="store_true",
help="trace all lookups (default is fails only)")
parser.add_argument("--ebpf", action="store_true",
help=argparse.SUPPRESS)
args = parser.parse_args()
# define BPF progra
标签:argparse,lookups,py,parser,BCC,dcache,dcsnoop,import
From: https://blog.csdn.net/huangyabin001/article/details/136751377