小工具知识网

当前位置: 首页 > 行业知识 > 5.52 BCC工具之dbslower.py解读

行业知识

5.52 BCC工具之dbslower.py解读

2026-11-17 01:24:14 来源:互联网转载

一,工具简介

dbslower工具用于追踪由 MySQL 或 PostgreSQL 服务器提供的查询,并打印出那些超过延迟(查询时间)阈值的查询。默认情况下,使用的阈值是 1 毫秒。

()

二,代码示例

#!/usr/bin/env pythonfrom bcc import BPF, USDTimport argparseimport reimport subprocessexamples = """examples:    dbslower postgres            # trace PostgreSQL queries slower than 1ms    dbslower postgres -p 188 322 # trace specific PostgreSQL processes    dbslower mysql -p 480 -m 30  # trace MySQL queries slower than 30ms    dbslower mysql -p 480 -v     # trace MySQL queries & print the BPF program    dbslower mysql -x $(which mysqld)  # trace MySQL queries with uprobes"""parser = argparse.ArgumentParser(    description="",    formatter_class=argparse.RawDescriptionHelpFormatter,    epilog=examples)parser.add_argument("-v", "--verbose", action="store_true",    help="print the BPF program")par
()

上一篇:Discuz手机热帖图文展示秘籍,轻松掌握图文攻略,一窥热帖风采!

下一篇:魔兽世界字体美化秘籍,轻松改变游戏文字风格,让你的界面焕然一新!