|
22 | 22 |
|
23 | 23 | from bcc import BPF
|
24 | 24 | from time import sleep, strftime
|
| 25 | +import argparse |
25 | 26 | import sys
|
26 | 27 | import os
|
27 | 28 | repo_lib_dir = os.path.dirname(__file__) + "/../../lib/"
|
|
46 | 47 | #include <sys/zil_impl.h>
|
47 | 48 | """
|
48 | 49 |
|
49 |
| -if len(sys.argv) > 1: |
50 |
| - bpf_text += '#define POOL "' + sys.argv[1] + '"' |
| 50 | +parser = argparse.ArgumentParser( |
| 51 | + description='Collect zil latency statistics.', |
| 52 | + usage='estat zil [options]') |
| 53 | +parser.add_argument('-c', '--coll', type=int, action='store', |
| 54 | + dest='collection_sec', |
| 55 | + help='The collection interval in seconds') |
| 56 | +parser.add_argument('-p', '--pool', type=str, action='store', |
| 57 | + dest='pool', |
| 58 | + help='The pool to monitor (default: domain0)') |
| 59 | +args = parser.parse_args() |
| 60 | + |
| 61 | +if (args.pool): |
| 62 | + bpf_text += '#define POOL "' + str(args.pool) + '"' |
51 | 63 | else:
|
52 | 64 | bpf_text += '#define POOL "domain0"'
|
53 | 65 |
|
|
276 | 288 | BCCHelper.AVERAGE_AGGREGATION, "avg")
|
277 | 289 | alloc_helper.add_key_type("name")
|
278 | 290 |
|
279 |
| -print(" Tracing enabled... Hit Ctrl-C to end.") |
| 291 | +if (not args.collection_sec): |
| 292 | + print(" Tracing enabled... Hit Ctrl-C to end.") |
| 293 | + |
| 294 | +# Collect data for a collection interval if specified |
| 295 | +if (args.collection_sec): |
| 296 | + sleep(args.collection_sec) |
| 297 | + try: |
| 298 | + print("%-16s\n" % strftime("%D - %H:%M:%S %Z")) |
| 299 | + latency_helper.printall() |
| 300 | + alloc_helper.printall() |
| 301 | + exit(0) |
| 302 | + except Exception as e: |
| 303 | + print(str(e)) |
| 304 | + exit(0) |
| 305 | + |
| 306 | +# Collect data until keyborad interrupt with output for each second |
280 | 307 | while (1):
|
281 | 308 | try:
|
282 | 309 | sleep(60)
|
|
0 commit comments