diff options
author | Janosch Frank <frankja@linux.vnet.ibm.com> | 2016-01-11 16:18:03 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-01-26 15:58:13 +0100 |
commit | 7f786a9a06cc100b1261b120c7698083a802d46c (patch) | |
tree | 553ac6142ea196756575be94dc65161b2e1f3717 | |
parent | 126b33e6191cd21ba7e05673eb1428b73bf2d34e (diff) | |
download | qemu-7f786a9a06cc100b1261b120c7698083a802d46c.zip qemu-7f786a9a06cc100b1261b120c7698083a802d46c.tar.gz qemu-7f786a9a06cc100b1261b120c7698083a802d46c.tar.bz2 |
scripts/kvm/kvm_stat: Add interactive filtering
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 <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-34-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rwxr-xr-x | scripts/kvm/kvm_stat | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index eb97a65..25631a4 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -634,6 +634,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: @@ -647,6 +669,8 @@ class Tui(object): self.update_drilldown() if char == 'q': break + if char == 'f': + self.show_filter_selection() except KeyboardInterrupt: break except curses.error: |