diff --git a/iotop/ui.py b/iotop/ui.py index 7ae8bad..77f82c7 100644 --- a/iotop/ui.py +++ b/iotop/ui.py @@ -224,6 +224,12 @@ class IOTopUI(object): new_sorting_key += delta new_sorting_key = max(0, new_sorting_key) new_sorting_key = min(len(IOTopUI.sorting_keys) - 1, new_sorting_key) + if not self.has_swapin_io: + if new_sorting_key in (5, 6): + if delta <= 0: + new_sorting_key = 4 + elif delta > 0: + new_sorting_key = 7 return new_sorting_key # I wonder if switching to urwid for the display would be better here @@ -421,14 +427,22 @@ class IOTopUI(object): def format(p): stats = format_stats(self.options, p, self.process_list.duration) io_delay, swapin_delay, read_bytes, write_bytes = stats + format = '%%%dd' % MAX_PID_WIDTH + params = p.pid, + format += ' %4s' + params += p.get_ioprio(), + format += ' %-8s' + params += p.get_user()[:8], + format += ' %11s %11s' + params += read_bytes, write_bytes if self.has_swapin_io: - delay_stats = '%7s %7s ' % (swapin_delay, io_delay) - else: - delay_stats = ' ?unavailable? ' - pid_format = '%%%dd' % MAX_PID_WIDTH - line = (pid_format + ' %4s %-8s %11s %11s %s') % ( - p.pid, p.get_ioprio(), p.get_user()[:8], read_bytes, - write_bytes, delay_stats) + format += ' %7s %7s' + params += swapin_delay, io_delay + elif self.options.batch: + format += ' %s ' + params += '?unavailable?', + format += ' ' + line = format % (params) cmdline = p.get_cmdline() if not self.options.batch: remaining_length = self.width - len(line) @@ -481,6 +495,7 @@ class IOTopUI(object): # and iotop then uses the sysctl value instead. if sysctl_task_delayacct() == False: self.has_swapin_io = False + self.adjust_sorting_key(0) lines = self.get_data() if self.options.time: titles = [' TIME'] + titles @@ -571,6 +586,8 @@ class IOTopUI(object): pos = 0 remaining_cols = self.width for i in range(len(titles)): + if not self.has_swapin_io and i in (5, 6): + continue attr = curses.A_REVERSE title = titles[i] if i == self.sorting_key: