一,工具简介
funccount工具可以追踪与指定模式匹配的函数、追踪点或USDT探针,并会在追踪过程中打印它们的计数摘要。
二,代码示例
#!/usr/bin/env pythonfrom __future__ import print_function
from bcc import ArgString, BPF, USDT
from time import sleep, strftime
import argparse
import re
import signal
import sys
import tracebackdebug = Falsedef verify_limit(num):probe_limit = BPF.get_probe_limit()if num > probe_limit:raise Exception("maximum of %d probes allowed, attempted %d" %(probe_limit, num))class Probe(object):def __init__(self, pattern, use_regex=False, pid=None, cpu=None):"""Init a new probe.Init the probe from the pattern provided by the user. The supportedpatterns mimic the 'trace' and 'argdist' tools, but are simpler becausewe don't have to distinguish between probes and retprobes.func -