| .. | .. | 
|---|
| 5 | 5 | # Displays system-wide failed system call totals, broken down by pid. | 
|---|
| 6 | 6 | # If a [comm] arg is specified, only syscalls called by [comm] are displayed. | 
|---|
| 7 | 7 |  | 
|---|
|  | 8 | +from __future__ import print_function | 
|---|
|  | 9 | + | 
|---|
| 8 | 10 | import os | 
|---|
| 9 | 11 | import sys | 
|---|
| 10 | 12 |  | 
|---|
| .. | .. | 
|---|
| 32 | 34 | syscalls = autodict() | 
|---|
| 33 | 35 |  | 
|---|
| 34 | 36 | def trace_begin(): | 
|---|
| 35 |  | -	print "Press control+C to stop and show the summary" | 
|---|
|  | 37 | +	print("Press control+C to stop and show the summary") | 
|---|
| 36 | 38 |  | 
|---|
| 37 | 39 | def trace_end(): | 
|---|
| 38 | 40 | print_error_totals() | 
|---|
| .. | .. | 
|---|
| 56 | 58 | raw_syscalls__sys_exit(**locals()) | 
|---|
| 57 | 59 |  | 
|---|
| 58 | 60 | def print_error_totals(): | 
|---|
| 59 |  | -    if for_comm is not None: | 
|---|
| 60 |  | -	    print "\nsyscall errors for %s:\n\n" % (for_comm), | 
|---|
| 61 |  | -    else: | 
|---|
| 62 |  | -	    print "\nsyscall errors:\n\n", | 
|---|
|  | 61 | +	if for_comm is not None: | 
|---|
|  | 62 | +		print("\nsyscall errors for %s:\n" % (for_comm)) | 
|---|
|  | 63 | +	else: | 
|---|
|  | 64 | +		print("\nsyscall errors:\n") | 
|---|
| 63 | 65 |  | 
|---|
| 64 |  | -    print "%-30s  %10s\n" % ("comm [pid]", "count"), | 
|---|
| 65 |  | -    print "%-30s  %10s\n" % ("------------------------------", \ | 
|---|
| 66 |  | -                                 "----------"), | 
|---|
|  | 66 | +	print("%-30s  %10s" % ("comm [pid]", "count")) | 
|---|
|  | 67 | +	print("%-30s  %10s" % ("------------------------------", "----------")) | 
|---|
| 67 | 68 |  | 
|---|
| 68 |  | -    comm_keys = syscalls.keys() | 
|---|
| 69 |  | -    for comm in comm_keys: | 
|---|
| 70 |  | -	    pid_keys = syscalls[comm].keys() | 
|---|
| 71 |  | -	    for pid in pid_keys: | 
|---|
| 72 |  | -		    print "\n%s [%d]\n" % (comm, pid), | 
|---|
| 73 |  | -		    id_keys = syscalls[comm][pid].keys() | 
|---|
| 74 |  | -		    for id in id_keys: | 
|---|
| 75 |  | -			    print "  syscall: %-16s\n" % syscall_name(id), | 
|---|
| 76 |  | -			    ret_keys = syscalls[comm][pid][id].keys() | 
|---|
| 77 |  | -			    for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda(k, v): (v, k),  reverse = True): | 
|---|
| 78 |  | -				    print "    err = %-20s  %10d\n" % (strerror(ret), val), | 
|---|
|  | 69 | +	comm_keys = syscalls.keys() | 
|---|
|  | 70 | +	for comm in comm_keys: | 
|---|
|  | 71 | +		pid_keys = syscalls[comm].keys() | 
|---|
|  | 72 | +		for pid in pid_keys: | 
|---|
|  | 73 | +			print("\n%s [%d]" % (comm, pid)) | 
|---|
|  | 74 | +			id_keys = syscalls[comm][pid].keys() | 
|---|
|  | 75 | +			for id in id_keys: | 
|---|
|  | 76 | +				print("  syscall: %-16s" % syscall_name(id)) | 
|---|
|  | 77 | +				ret_keys = syscalls[comm][pid][id].keys() | 
|---|
|  | 78 | +				for ret, val in sorted(syscalls[comm][pid][id].items(), key = lambda kv: (kv[1], kv[0]), reverse = True): | 
|---|
|  | 79 | +					print("    err = %-20s  %10d" % (strerror(ret), val)) | 
|---|