<s> from __future__ import print_function <EOL> from bcc import BPF <EOL> from time import sleep , strftime <EOL> import argparse <EOL> import signal <EOL> from subprocess import call <EOL> examples = """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( <EOL> description = "<STR_LIT>" , <EOL> formatter_class = argparse . RawDescriptionHelpFormatter , <EOL> epilog = examples ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , default = <NUM_LIT:20> , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , nargs = "<STR_LIT:?>" , default = <NUM_LIT:1> , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT:count>" , nargs = "<STR_LIT:?>" , default = <NUM_LIT> , <EOL> help = "<STR_LIT>" ) <EOL> args = parser . parse_args ( ) <EOL> interval = int ( args . interval ) <EOL> countdown = int ( args . count ) <EOL> maxrows = int ( args . maxrows ) <EOL> clear = not int ( args . noclear ) <EOL> debug = <NUM_LIT:0> <EOL> loadavg = "<STR_LIT>" <EOL> def signal_ignore ( signal , frame ) : <EOL> print ( ) <EOL> bpf_text = """<STR_LIT>""" <EOL> if args . pid : <EOL> bpf_text = bpf_text . replace ( '<STR_LIT>' , '<STR_LIT>' % args . pid ) <EOL> else : <EOL> bpf_text = bpf_text . replace ( '<STR_LIT>' , '<STR_LIT:0>' ) <EOL> if debug : <EOL> print ( bpf_text ) <EOL> b = BPF ( text = bpf_text ) <EOL> b . attach_kprobe ( event = "<STR_LIT>" , fn_name = "<STR_LIT>" ) <EOL> b . attach_kprobe ( event = "<STR_LIT>" , fn_name = "<STR_LIT>" ) <EOL> print ( '<STR_LIT>' % interval ) <EOL> exiting = <NUM_LIT:0> <EOL> while <NUM_LIT:1> : <EOL> try : <EOL> sleep ( interval ) <EOL> except KeyboardInterrupt : <EOL> exiting = <NUM_LIT:1> <EOL> if clear : <EOL> call ( "<STR_LIT>" ) <EOL> else : <EOL> print ( ) <EOL> with open ( loadavg ) as stats : <EOL> print ( "<STR_LIT>" % ( strftime ( "<STR_LIT>" ) , stats . read ( ) ) ) <EOL> print ( "<STR_LIT>" % ( "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:T>" , "<STR_LIT>" ) ) <EOL> counts = b . get_table ( "<STR_LIT>" ) <EOL> line = <NUM_LIT:0> <EOL> for k , v in reversed ( sorted ( counts . items ( ) , <EOL> key = lambda counts : counts [ <NUM_LIT:1> ] . rbytes ) ) : <EOL> print ( "<STR_LIT>" % ( k . pid , k . name , <EOL> v . reads , v . writes , v . rbytes / <NUM_LIT> , v . wbytes / <NUM_LIT> , k . type , <EOL> k . file ) ) <EOL> line += <NUM_LIT:1> <EOL> if line >= maxrows : <EOL> break <EOL> counts . clear ( ) <EOL> countdown -= <NUM_LIT:1> <EOL> if exiting or countdown == <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" ) <EOL> exit ( ) </s>
