def get_args(): parser = argparse.ArgumentParser( description="Summarize syscall counts and latencies.") parser.add_argument("-p", "--pid", type=int, help="trace only this pid") parser.add_argument("-i", "--interval", type=int, help="print summary at this interval (seconds)") parser.add_argument("-d", "--duration", type=int, help="total duration of trace, in seconds") parser.add_argument("-T", "--top", type=int, default=500, help="print only the top syscalls by count or latency") parser.add_argument("-x", "--failures", action="store_true", help="trace only failed syscalls (return < 0)") parser.add_argument( "-e", "--errno", type=handle_errno, help= "trace only syscalls that return this error (numeric or EPERM, etc.)") parser.add_argument( "-m", "--milliseconds", action="store_true", help="display latency in milliseconds (default: microseconds)") parser.add_argument( "-P", "--port", type=int, help="the port number which is used to export metrics to prometheus") parser.add_argument("-l", "--list", action="store_true", help="print list of recognized syscalls and exit") parser.add_argument("--process", help="monitor only this process name") parser.add_argument( "--data-dir", dest="data_dir", required=True, help="the data directory to be monitored for file reads and writes") parser.add_argument("--ebpf", action="store_true", help=argparse.SUPPRESS) args = parser.parse_args() if args.duration and not args.interval: args.interval = args.duration if not args.interval: args.interval = 99999999 if not args.port: args.port = 8000 if args.list: if sys.version_info.major < 3: izip_longest = itertools.izip_longest else: izip_longest = itertools.zip_longest for grp in izip_longest(*(iter(sorted(syscalls.values())), ) * 4): print(" ".join(["%-20s" % s for s in grp if s is not None])) sys.exit(0) return args
parser.add_argument("-l", "--list", action="store_true", help="print list of recognized syscalls and exit") parser.add_argument("--process", help="monitor only this process name") parser.add_argument("--ebpf", action="store_true", help=argparse.SUPPRESS) args = parser.parse_args() if args.duration and not args.interval: args.interval = args.duration if not args.interval: args.interval = 99999999 if not args.port: args.port = 8000 if args.list: for grp in izip_longest(*(iter(sorted(syscalls.values())), ) * 4): print(" ".join([ "%-20s" % s.decode(encoding='utf-8', errors='strict') for s in grp if s is not None ])) sys.exit(0) text = """ #include <linux/sched.h> #ifdef LATENCY struct data_t { long error_no; u64 count; u64 total_ns; };
parser.add_argument("-m", "--milliseconds", action="store_true", help="display latency in milliseconds (default: microseconds)") parser.add_argument("-P", "--process", action="store_true", help="count by process and not by syscall") parser.add_argument("-l", "--list", action="store_true", help="print list of recognized syscalls and exit") parser.add_argument("--ebpf", action="store_true", help=argparse.SUPPRESS) args = parser.parse_args() if args.duration and not args.interval: args.interval = args.duration if not args.interval: args.interval = 99999999 if args.list: for grp in izip_longest(*(iter(sorted(syscalls.values())),) * 4): print(" ".join(["%-20s" % s for s in grp if s is not None])) sys.exit(0) text = """ #ifdef LATENCY struct data_t { u64 count; u64 total_ns; }; BPF_HASH(start, u64, u64); BPF_HASH(data, u32, struct data_t); #else BPF_HASH(data, u32, u64); #endif