Skip to content

Commit

Permalink
Misc fixes on Python tools (iovisor#2136)
Browse files Browse the repository at this point in the history
Misc fixes on Python tools
  • Loading branch information
palmtenor authored and yonghong-song committed Jan 11, 2019
1 parent 6a0a791 commit aaca976
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tools/biotop.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
diskstats = "/proc/diskstats"

# signal handler
def signal_ignore(signal, frame):
def signal_ignore(signal_value, frame):
print()

# load BPF program
Expand Down
6 changes: 3 additions & 3 deletions tools/cachetop.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"WRITE_HIT%"
)
DEFAULT_FIELD = "HITS"

DEFAULT_SORT_FIELD = FIELDS.index(DEFAULT_FIELD)

# signal handler
def signal_ignore(signal, frame):
Expand All @@ -61,7 +61,7 @@ def get_meminfo():

def get_processes_stats(
bpf,
sort_field=FIELDS.index(DEFAULT_FIELD),
sort_field=DEFAULT_SORT_FIELD,
sort_reverse=False):
'''
Return a tuple containing:
Expand Down Expand Up @@ -223,7 +223,7 @@ def handle_loop(stdscr, args):
uid = int(stat[1])
try:
username = pwd.getpwuid(uid)[0]
except KeyError as ex:
except KeyError:
# `pwd` throws a KeyError if the user cannot be found. This can
# happen e.g. when the process is running in a cgroup that has
# different users from the host.
Expand Down
2 changes: 1 addition & 1 deletion tools/criticalstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def print_event(cpu, data, size):
print("NO STACK FOUND DUE TO COLLISION")
print("===================================")
print("")
except:
except Exception:
sys.exit(0)

b["events"].open_perf_buffer(print_event, page_cnt=256)
Expand Down
2 changes: 1 addition & 1 deletion tools/fileslower.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
try:
b.attach_kprobe(event="__vfs_write", fn_name="trace_write_entry")
b.attach_kretprobe(event="__vfs_write", fn_name="trace_write_return")
except:
except Exception:
# older kernels don't have __vfs_write so try vfs_write instead
b.attach_kprobe(event="vfs_write", fn_name="trace_write_entry")
b.attach_kretprobe(event="vfs_write", fn_name="trace_write_return")
Expand Down
2 changes: 1 addition & 1 deletion tools/filetop.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
loadavg = "/proc/loadavg"

# signal handler
def signal_ignore(signal, frame):
def signal_ignore(signal_value, frame):
print()

# define BPF program
Expand Down
4 changes: 2 additions & 2 deletions tools/lib/uflow_example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ CPU PID TID TIME(us) METHOD
3 27722 27731 3.144 <- java/lang/ThreadGroup.checkAccess
3 27722 27731 3.144 -> java/lang/ThreadGroup.addUnstarted
3 27722 27731 3.144 <- java/lang/ThreadGroup.addUnstarted
3 27722 27731 3.145 -> java/lang/Thread.isDaemon
3 27722 27731 3.145 <- java/lang/Thread.isDaemon
3 27722 27731 3.145 -> java/lang/Thread.isDaemon
3 27722 27731 3.145 <- java/lang/Thread.isDaemon
3 27722 27731 3.145 -> java/lang/Thread.getPriority
3 27722 27731 3.145 <- java/lang/Thread.getPriority
3 27722 27731 3.145 -> java/lang/Thread.getContextClassLoader
Expand Down
2 changes: 1 addition & 1 deletion tools/llcstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
b.attach_perf_event(
ev_type=PerfType.HARDWARE, ev_config=PerfHWConfig.CACHE_REFERENCES,
fn_name="on_cache_ref", sample_period=args.sample_period)
except:
except Exception:
print("Failed to attach to a hardware event. Is this a virtual machine?")
exit()

Expand Down
2 changes: 1 addition & 1 deletion tools/runqslower.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
else:
bpf_text = bpf_text.replace('FILTER_US', 'delta_us <= %s' % str(min_us))
if args.pid:
bpf_text = bpf_text.replace('FILTER_PID', 'pid != %s' % pid)
bpf_text = bpf_text.replace('FILTER_PID', 'pid != %s' % args.pid)
else:
bpf_text = bpf_text.replace('FILTER_PID', '0')
if debug or args.ebpf:
Expand Down

0 comments on commit aaca976

Please sign in to comment.