From 812dfd00930551f9813a87d4376fe82ee61db90d Mon Sep 17 00:00:00 2001 From: Guillaume Chazarain Date: Mon, 4 May 2009 00:00:45 +0200 Subject: [PATCH] Added --quiet --- NEWS | 2 +- THANKS | 2 +- iotop.1 | 16 ++++++++++++++++ iotop/ui.py | 16 +++++++++++----- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index ac0e617..093ad6e 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ ~~~ o -P is now fully implemented and is dynamically toggled with 'p' o Show the I/O priority -o Added the --accumulated, --kilobytes and --time options +o Added the --accumulated, --kilobytes, --time and --quiet options 0.2.1 ~~~~~ diff --git a/THANKS b/THANKS index d072fc4..ec29d67 100644 --- a/THANKS +++ b/THANKS @@ -19,4 +19,4 @@ Ryan Lovett output file is updated. Martin Bammer - Initial implementation of the --time option. + Initial implementation of the --time and --quiet options. diff --git a/iotop.1 b/iotop.1 index a7d4f93..67bed3b 100644 --- a/iotop.1 +++ b/iotop.1 @@ -60,6 +60,22 @@ Use kilobytes instead of a human friendly unit. This mode is useful when scripti .TP \fB\-t\fR, \fB\-\-time\fR Add a timestamp on each line (implies --batch). Each line will be prefixed by the current time. +.TP +\fB\-q\fR, \fB\-\-quiet\fR +suppress some lines of header (implies --batch). This option can be specified up to three times to remove header lines. +.RS +.PD 0 +.TP +.B -q +column names are only printed on the first iteration, +.TP +.B -qq +column names are never printed, +.TP +.B -qqq +the I/O summary is never printed. +.PD 1 +.RE .SH SEE ALSO .BR top (1), .BR vmstat (1) diff --git a/iotop/ui.py b/iotop/ui.py index 60d85eb..e7f3cdd 100644 --- a/iotop/ui.py +++ b/iotop/ui.py @@ -108,12 +108,14 @@ class IOTopUI(object): iterations < self.options.iterations: total = self.process_list.refresh_processes() total_read, total_write = total - self.refresh_display(total_read, total_write, + self.refresh_display(iterations == 0, total_read, total_write, self.process_list.duration) if self.options.iterations is not None: iterations += 1 if iterations >= self.options.iterations: break + elif iterations == 0: + iterations = 1 try: events = poll.poll(self.options.delay_seconds * 1000.0) @@ -205,7 +207,7 @@ class IOTopUI(object): del processes[self.height - 2:] return map(format, processes) - def refresh_display(self, total_read, total_write, duration): + def refresh_display(self, first_time, total_read, total_write, duration): summary = 'Total DISK READ: %s | Total DISK WRITE: %s' % ( format_bandwidth(self.options, total_read, duration), format_bandwidth(self.options, total_write, duration)) @@ -221,8 +223,10 @@ class IOTopUI(object): current_time = time.strftime('%H:%M:%S ') lines = [current_time + l for l in lines] if self.options.batch: - print summary - print ''.join(titles) + if self.options.quiet <= 2: + print summary + if self.options.quiet <= int(first_time): + print ''.join(titles) for l in lines: print l sys.stdout.flush() @@ -332,6 +336,8 @@ def main(): 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', + help='suppress some lines of header (implies --batch)') parser.add_option('--profile', action='store_true', dest='profile', default=False, help=optparse.SUPPRESS_HELP) @@ -340,7 +346,7 @@ def main(): parser.error('Unexpected arguments: ' + ' '.join(args)) find_uids(options) options.pids = options.pids or [] - options.batch = options.batch or options.time + options.batch = options.batch or options.time or options.quiet main_loop = lambda: run_iotop(options) -- 2.11.4.GIT