Skip to content

Commit

Permalink
commas in the output of keys in estat
Browse files Browse the repository at this point in the history
estat: too many arguments output when there are too few
estat: remove mandatory final positional duration argument

closes delphix#10, closes delphix#14, and closes delphix#16
  • Loading branch information
brad-lewis committed Jan 10, 2020
1 parent 21b6666 commit 25ee8ed
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
33 changes: 30 additions & 3 deletions bpf/standalone/zil.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from bcc import BPF
from time import sleep, strftime
import argparse
import sys
import os
repo_lib_dir = os.path.dirname(__file__) + "/../../lib/"
Expand All @@ -46,8 +47,19 @@
#include <sys/zil_impl.h>
"""

if len(sys.argv) > 1:
bpf_text += '#define POOL "' + sys.argv[1] + '"'
parser = argparse.ArgumentParser(
description='Collect zil latency statistics.',
usage='estat zil [options]')
parser.add_argument('-c', '--coll', type=int, action='store',
dest='collection_sec',
help='The collection interval in seconds')
parser.add_argument('-p', '--pool', type=str, action='store',
dest='pool',
help='The pool to monitor (default: domain0)')
args = parser.parse_args()

if (args.pool):
bpf_text += '#define POOL "' + str(args.pool) + '"'
else:
bpf_text += '#define POOL "domain0"'

Expand Down Expand Up @@ -276,7 +288,22 @@
BCCHelper.AVERAGE_AGGREGATION, "avg")
alloc_helper.add_key_type("name")

print(" Tracing enabled... Hit Ctrl-C to end.")
if (not args.collection_sec):
print(" Tracing enabled... Hit Ctrl-C to end.")

# Collect data for a collection interval if specified
if (args.collection_sec):
sleep(args.collection_sec)
try:
print("%-16s\n" % strftime("%D - %H:%M:%S %Z"))
latency_helper.printall()
alloc_helper.printall()
exit(0)
except Exception as e:
print(str(e))
exit(0)

# Collect data until keyborad interrupt with output for each second
while (1):
try:
sleep(60)
Expand Down
3 changes: 3 additions & 0 deletions lib/bcchelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ def items_to_string(self, agg_items):
stripped_key = ""
try:
stripped_key = keystr[keystr.index(',')+1:len(keystr)-1]
stripped_key = stripped_key.strip()
if stripped_key[-1:] == ",":
stripped_key = stripped_key[:-1]
except ValueError:
pass

Expand Down

0 comments on commit 25ee8ed

Please sign in to comment.