Tools lint cleanup (#764)
* argdist: linter cleanup
* cpudist: linter cleanup
* execsnoop: linter cleanup
* funclatency: linter cleanup
* gethostlatency: linter cleanup
* hardirqs: linter cleanup
* memleak: linter cleanup
* mountsnoop: linter cleanup
* offcputime: linter cleanup
* softirqs: linter cleanup
* solisten: linter cleanup and u+x mode
* stacksnoop: linter cleanup
* tplist: linter cleanup
* trace: linter cleanup
diff --git a/tools/solisten.py b/tools/solisten.py
old mode 100644
new mode 100755
index 9797672..1192654
--- a/tools/solisten.py
+++ b/tools/solisten.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
#
-# solisten Trace TCP listen events
-# For Linux, uses BCC, eBPF. Embedded C.
+# solisten Trace TCP listen events
+# For Linux, uses BCC, eBPF. Embedded C.
#
# USAGE: solisten.py [-h] [-p PID] [--show-netns]
#
@@ -28,8 +28,8 @@
examples = """Examples:
./solisten.py # Stream socket listen
./solisten.py -p 1234 # Stream socket listen for specified PID only
- ./solisten.py --netns 4242 # Stream socket listen for specified network namespace ID only
- ./solisten.py --show-netns # Show network namespace ID. Probably usefull if you run containers
+ ./solisten.py --netns 4242 # " for the specified network namespace ID only
+ ./solisten.py --show-netns # Show network ns ID (useful for containers)
"""
parser = argparse.ArgumentParser(
@@ -45,7 +45,7 @@
# BPF Program
-bpf_text = """
+bpf_text = """
#include <net/sock.h>
#include <net/inet_sock.h>
#include <net/net_namespace.h>
@@ -77,7 +77,8 @@
.backlog = backlog,
};
- // Get process comm. Needs LLVM >= 3.7.1 see https://github.com/iovisor/bcc/issues/393
+ // Get process comm. Needs LLVM >= 3.7.1
+ // see https://github.com/iovisor/bcc/issues/393
bpf_get_current_comm(evt.task, TASK_COMM_LEN);
// Get socket IP family
@@ -107,7 +108,8 @@
bpf_probe_read(evt.laddr, sizeof(u32), &(inet->inet_rcv_saddr));
evt.laddr[0] = be32_to_cpu(evt.laddr[0]);
} else if (family == AF_INET6) {
- bpf_probe_read(evt.laddr, sizeof(evt.laddr), sk->__sk_common.skc_v6_rcv_saddr.in6_u.u6_addr32);
+ bpf_probe_read(evt.laddr, sizeof(evt.laddr),
+ sk->__sk_common.skc_v6_rcv_saddr.in6_u.u6_addr32);
evt.laddr[0] = be64_to_cpu(evt.laddr[0]);
evt.laddr[1] = be64_to_cpu(evt.laddr[1]);
}
@@ -157,7 +159,8 @@
protocol += "v4"
address = netaddr.IPAddress(event.laddr[0])
elif proto_type == socket.AF_INET6:
- address = netaddr.IPAddress(event.laddr[0]<<64 | event.laddr[1], version=6)
+ address = netaddr.IPAddress(event.laddr[0] << 64 | event.laddr[1],
+ version=6)
protocol += "v6"
# Display
@@ -195,11 +198,12 @@
# Print headers
if args.show_netns:
- print("%-6s %-12s %-12s %-6s %-8s %-5s %-39s" % ("PID", "COMM", "NETNS", "PROTO", "BACKLOG", "PORT", "ADDR"))
+ print("%-6s %-12s %-12s %-6s %-8s %-5s %-39s" %
+ ("PID", "COMM", "NETNS", "PROTO", "BACKLOG", "PORT", "ADDR"))
else:
- print("%-6s %-12s %-6s %-8s %-5s %-39s" % ("PID", "COMM", "PROTO", "BACKLOG", "PORT", "ADDR"))
+ print("%-6s %-12s %-6s %-8s %-5s %-39s" %
+ ("PID", "COMM", "PROTO", "BACKLOG", "PORT", "ADDR"))
# Read events
while 1:
b.kprobe_poll()
-