5.53 BCC工具之dbslower.py解读

一,工具简介

dbstat用于追踪由MySQL或PostgreSQL数据库进程执行的查询,并显示查询延迟的直方图。

二,代码示例

#!/usr/bin/env python

from bcc import BPF, USDT
import argparse
import subprocess
from time import sleep, strftime

examples = """
    dbstat postgres     # display a histogram of PostgreSQL query latencies
    dbstat mysql -v     # display MySQL latencies and print the BPF program
    dbstat mysql -u     # display query latencies in microseconds (default: ms)
    dbstat mysql -m 5   # trace only queries slower than 5ms
    dbstat mysql -p 408 # trace queries in a specific process
"""
parser = argparse.ArgumentParser(
    description="",
    formatter_class=argparse.RawDescriptionHelpFormatter,
    epilog=examples)
parser.add_argument("-v", "--verbose", action="store_true",
    help="print the BPF program")
parser.add_argument("db", choices=["mysql", &

你可能感兴趣的:(Android,eBPF,Book,linux,ebpf,android,python,bcc)