def main(): parser = optparse.OptionParser(usage=USAGE, version='iotop ' + VERSION) parser.add_option('-o', '--only', action='store_true', dest='only', default=False, help='only show processes or threads actually doing I/O') parser.add_option('-b', '--batch', action='store_true', dest='batch', help='non-interactive mode') parser.add_option('-n', '--iter', type='int', dest='iterations', metavar='NUM', help='number of iterations before ending [infinite]') parser.add_option('-d', '--delay', type='float', dest='delay_seconds', help='delay between iterations [1 second]', metavar='SEC', default=1) parser.add_option('-p', '--pid', type='int', dest='pids', action='append', help='processes to monitor [all]', metavar='PID') parser.add_option('-u', '--user', type='str', dest='users', action='append', help='users to monitor [all]', metavar='USER') parser.add_option('-P', '--processes', action='store_true', dest='processes', help='only show processes, not all threads') options, args = parser.parse_args() if args: parser.error('Unexpected arguments: ' + ' '.join(args)) find_uids(options) options.pids = options.pids or [] if options.batch: run_iotop(None, options) else: curses.wrapper(run_iotop, options)
def main(): try: locale.setlocale(locale.LC_ALL, '') except locale.Error: print('unable to set locale, falling back to the default locale') parser = optparse.OptionParser(usage=USAGE, version='iotop ' + VERSION) parser.add_option('-o', '--only', action='store_true', dest='only', default=False, help='only show processes or threads actually doing I/O') parser.add_option('-b', '--batch', action='store_true', dest='batch', help='non-interactive mode') parser.add_option('-n', '--iter', type='int', dest='iterations', metavar='NUM', help='number of iterations before ending [infinite]') parser.add_option('-d', '--delay', type='float', dest='delay_seconds', help='delay between iterations [1 second]', metavar='SEC', default=1) parser.add_option('-p', '--pid', type='int', dest='pids', action='append', help='processes/threads to monitor [all]', metavar='PID') parser.add_option('-u', '--user', type='str', dest='users', action='append', help='users to monitor [all]', metavar='USER') parser.add_option('-g', '--cgroup', type='str', dest='cgroups', action='append', help='cgroups to monitor [all]', metavar='CGROUP') parser.add_option('-P', '--processes', action='store_true', dest='processes', default=False, help='only show processes, not all threads') parser.add_option('-a', '--accumulated', action='store_true', dest='accumulated', default=False, help='show accumulated I/O instead of bandwidth') parser.add_option('-k', '--kilobytes', action='store_true', dest='kilobytes', default=False, help='use kilobytes instead of a human friendly unit') parser.add_option('-t', '--time', action='store_true', dest='time', help='add a timestamp on each line (implies --batch)') parser.add_option('-q', '--quiet', action='count', dest='quiet', default=0, help='suppress some lines of header (implies --batch)') parser.add_option('--profile', action='store_true', dest='profile', default=False, help=optparse.SUPPRESS_HELP) options, args = parser.parse_args() if args: parser.error('Unexpected arguments: ' + ' '.join(args)) find_uids(options) options.pids = options.pids or [] options.batch = options.batch or options.time or options.quiet main_loop = lambda: run_iotop(options) if options.profile: def safe_main_loop(): try: main_loop() except Exception: pass _profile(safe_main_loop) else: main_loop()
def main(): try: locale.setlocale(locale.LC_ALL, '') except locale.Error: print('unable to set locale, falling back to the default locale') parser = optparse.OptionParser(usage=USAGE, version='iotop ' + VERSION) parser.add_option('-o', '--only', action='store_true', dest='only', default=False, help='only show processes or threads actually doing I/O') parser.add_option('-b', '--batch', action='store_true', dest='batch', help='non-interactive mode') parser.add_option('-n', '--iter', type='int', dest='iterations', metavar='NUM', help='number of iterations before ending [infinite]') parser.add_option('-d', '--delay', type='float', dest='delay_seconds', help='delay between iterations [1 second]', metavar='SEC', default=1) parser.add_option('-p', '--pid', type='int', dest='pids', action='append', help='processes/threads to monitor [all]', metavar='PID') parser.add_option('-u', '--user', type='str', dest='users', action='append', help='users to monitor [all]', metavar='USER') parser.add_option('-P', '--processes', action='store_true', dest='processes', default=False, help='only show processes, not all threads') parser.add_option('-a', '--accumulated', action='store_true', dest='accumulated', default=False, help='show accumulated I/O instead of bandwidth') parser.add_option('-k', '--kilobytes', action='store_true', dest='kilobytes', default=False, help='use kilobytes instead of a human friendly unit') parser.add_option('-t', '--time', action='store_true', dest='time', help='add a timestamp on each line (implies --batch)') parser.add_option('-q', '--quiet', action='count', dest='quiet', default=0, help='suppress some lines of header (implies --batch)') parser.add_option('--profile', action='store_true', dest='profile', default=False, help=optparse.SUPPRESS_HELP) options, args = parser.parse_args() if args: parser.error('Unexpected arguments: ' + ' '.join(args)) find_uids(options) options.pids = options.pids or [] options.batch = options.batch or options.time or options.quiet main_loop = lambda: run_iotop(options) if options.profile: def safe_main_loop(): try: main_loop() except: pass _profile(safe_main_loop) else: main_loop()
def main(): try: locale.setlocale(locale.LC_ALL, "") except locale.Error: print("unable to set locale, falling back to the default locale") parser = optparse.OptionParser(usage=USAGE, version="iotop " + VERSION) parser.add_option( "-o", "--only", action="store_true", dest="only", default=False, help="only show processes or threads actually doing I/O", ) parser.add_option("-b", "--batch", action="store_true", dest="batch", help="non-interactive mode") parser.add_option( "-n", "--iter", type="int", dest="iterations", metavar="NUM", help="number of iterations before ending [infinite]", ) parser.add_option( "-d", "--delay", type="float", dest="delay_seconds", help="delay between iterations [1 second]", metavar="SEC", default=1, ) parser.add_option( "-p", "--pid", type="str", dest="pids", help="processes/threads to monitor [all]\n\ for example:-p python,chrome,2258", metavar="PID|PNAME", ) parser.add_option( "-u", "--user", type="str", dest="users", help="users to monitor [all]\n\ if you need to monitor multiple users,you can\ use / to separate each user\ for example:-u root/mysql/500", default="", # action='append', help='users to monitor [all]', metavar="USER", ) parser.add_option( "-P", "--processes", action="store_true", dest="processes", default=False, help="only show processes, not all threads", ) parser.add_option( "-a", "--accumulated", action="store_true", dest="accumulated", default=False, help="show accumulated I/O instead of bandwidth", ) parser.add_option( "-k", "--kilobytes", action="store_true", dest="kilobytes", default=False, help="use kilobytes instead of a human friendly unit", ) parser.add_option( "-t", "--time", action="store_true", dest="time", help="add a timestamp on each line (implies --batch)" ) parser.add_option( "-q", "--quiet", action="count", dest="quiet", default=0, help="suppress some lines of header (implies --batch)" ) parser.add_option("--profile", action="store_true", dest="profile", default=False, help=optparse.SUPPRESS_HELP) options, args = parser.parse_args() if args: parser.error("Unexpected arguments: " + " ".join(args)) find_uids(options) find_pids(options) options.batch = options.batch or options.time or options.quiet main_loop = lambda: run_iotop(options) if options.profile: def safe_main_loop(): try: main_loop() except Exception: pass _profile(safe_main_loop) else: main_loop()