From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a706o-0003I5-4E for qemu-devel@nongnu.org; Thu, 10 Dec 2015 07:14:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a706l-0003pe-IG for qemu-devel@nongnu.org; Thu, 10 Dec 2015 07:14:06 -0500 Received: from e06smtp06.uk.ibm.com ([195.75.94.102]:43629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a706l-0003p2-8c for qemu-devel@nongnu.org; Thu, 10 Dec 2015 07:14:03 -0500 Received: from localhost by e06smtp06.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Dec 2015 12:14:02 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 43E871B08061 for ; Thu, 10 Dec 2015 12:14:30 +0000 (GMT) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tBACE0i343974826 for ; Thu, 10 Dec 2015 12:14:00 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tBACE0HO025608 for ; Thu, 10 Dec 2015 05:14:00 -0700 From: Janosch Frank Date: Thu, 10 Dec 2015 13:13:04 +0100 Message-Id: <1449749584-23214-35-git-send-email-frankja@linux.vnet.ibm.com> In-Reply-To: <1449749584-23214-1-git-send-email-frankja@linux.vnet.ibm.com> References: <1449749584-23214-1-git-send-email-frankja@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 34/34] scripts/kvm/kvm_stat: Add interactive filtering List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: cornelia.huck@de.ibm.com, frankja@linux.vnet.ibm.com Interactively changing the filter is much more useful than the drilldown, because it is more versatile. With this patch, the filter can be changed by pressing 'f' in the text ui and entering a new filter regex. --- scripts/kvm/kvm_stat | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index 556e5ca..cd5c4d9 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -592,6 +592,28 @@ class Tui(object): row += 1 self.screen.refresh() + def show_filter_selection(self): + while True: + self.screen.erase() + self.screen.addstr(0, 0, + "Show statistics for events matching a regex.", + curses.A_BOLD) + self.screen.addstr(2, 0, + "Current regex: {0}" + .format(self.stats.fields_filter)) + self.screen.addstr(3, 0, "New regex: ") + curses.echo() + regex = self.screen.getstr() + curses.noecho() + if len(regex) == 0: + return + try: + re.compile(regex) + self.stats.fields_filter = regex + return + except re.error: + continue + def show_stats(self): sleeptime = 0.25 while True: @@ -605,6 +627,10 @@ class Tui(object): self.update_drilldown() if char == 'q': break + if char == 'p': + self.show_vm_selection() + if char == 'f': + self.show_filter_selection() except KeyboardInterrupt: break except curses.error: -- 2.3.0