From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIeFk-0001nG-7W for qemu-devel@nongnu.org; Mon, 11 Jan 2016 10:19:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIeFh-0001xP-ES for qemu-devel@nongnu.org; Mon, 11 Jan 2016 10:19:28 -0500 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:54049) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIeFg-0001vo-9V for qemu-devel@nongnu.org; Mon, 11 Jan 2016 10:19:24 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 11 Jan 2016 15:19:23 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 130AD1B08067 for ; Mon, 11 Jan 2016 15:19:22 +0000 (GMT) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u0BFJLtM35324158 for ; Mon, 11 Jan 2016 15:19:21 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u0BFJKoY019109 for ; Mon, 11 Jan 2016 08:19:20 -0700 From: Janosch Frank Date: Mon, 11 Jan 2016 16:18:03 +0100 Message-Id: <1452525484-32309-34-git-send-email-frankja@linux.vnet.ibm.com> In-Reply-To: <1452525484-32309-1-git-send-email-frankja@linux.vnet.ibm.com> References: <1452525484-32309-1-git-send-email-frankja@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v2 33/34] scripts/kvm/kvm_stat: Add interactive filtering List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: pbonzini@redhat.com Cc: frankja@linux.vnet.ibm.com, qemu-devel@nongnu.org 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. Signed-off-by: Janosch Frank --- scripts/kvm/kvm_stat | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index 9ed3ccf..f64d4e8 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -632,6 +632,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: @@ -645,6 +667,8 @@ class Tui(object): self.update_drilldown() if char == 'q': break + if char == 'f': + self.show_filter_selection() except KeyboardInterrupt: break except curses.error: -- 2.3.0