|
|
9bac43 |
From 38362f9d75028cdcd58b6facb605f71f2a22a9be Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: David Hildenbrand <david@redhat.com>
|
|
|
9bac43 |
Date: Tue, 17 Oct 2017 19:15:41 +0200
|
|
|
9bac43 |
Subject: [PATCH 36/69] tools/kvm_stat: add interactive command 'c'
|
|
|
9bac43 |
MIME-Version: 1.0
|
|
|
9bac43 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9bac43 |
Content-Transfer-Encoding: 8bit
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: David Hildenbrand <david@redhat.com>
|
|
|
9bac43 |
Message-id: <20171017191605.2378-16-david@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 77325
|
|
|
9bac43 |
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 15/39] tools/kvm_stat: add interactive command 'c'
|
|
|
9bac43 |
Bugzilla: 1497137
|
|
|
9bac43 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
Upstream-status: linux.git 4443084fa0cf85f91d357c8917b90504b784d925
|
|
|
9bac43 |
|
|
|
9bac43 |
Convertion of documentation (for man page generation) to texi.
|
|
|
9bac43 |
|
|
|
9bac43 |
commit 4443084fa0cf85f91d357c8917b90504b784d925
|
|
|
9bac43 |
Author: Stefan Raspl <raspl@linux.vnet.ibm.com>
|
|
|
9bac43 |
Date: Fri Mar 10 13:40:14 2017 +0100
|
|
|
9bac43 |
|
|
|
9bac43 |
tools/kvm_stat: add interactive command 'c'
|
|
|
9bac43 |
|
|
|
9bac43 |
Provide a real simple way to erase any active filter.
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
|
|
|
9bac43 |
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
|
|
|
9bac43 |
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
scripts/kvm/kvm_stat | 16 ++++++++++++----
|
|
|
9bac43 |
scripts/kvm/kvm_stat.texi | 3 +++
|
|
|
9bac43 |
2 files changed, 15 insertions(+), 4 deletions(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
|
|
|
9bac43 |
index f263312..676a92a 100755
|
|
|
9bac43 |
--- a/scripts/kvm/kvm_stat
|
|
|
9bac43 |
+++ b/scripts/kvm/kvm_stat
|
|
|
9bac43 |
@@ -861,6 +861,7 @@ DELAY_INITIAL = 0.25
|
|
|
9bac43 |
DELAY_REGULAR = 3.0
|
|
|
9bac43 |
MAX_GUEST_NAME_LEN = 48
|
|
|
9bac43 |
MAX_REGEX_LEN = 44
|
|
|
9bac43 |
+DEFAULT_REGEX = r'^[^\(]*$'
|
|
|
9bac43 |
|
|
|
9bac43 |
|
|
|
9bac43 |
class Tui(object):
|
|
|
9bac43 |
@@ -907,9 +908,9 @@ class Tui(object):
|
|
|
9bac43 |
def update_drilldown(self):
|
|
|
9bac43 |
"""Sets or removes a filter that only allows fields without braces."""
|
|
|
9bac43 |
if not self.stats.fields_filter:
|
|
|
9bac43 |
- self.stats.fields_filter = r'^[^\(]*$'
|
|
|
9bac43 |
+ self.stats.fields_filter = DEFAULT_REGEX
|
|
|
9bac43 |
|
|
|
9bac43 |
- elif self.stats.fields_filter == r'^[^\(]*$':
|
|
|
9bac43 |
+ elif self.stats.fields_filter == DEFAULT_REGEX:
|
|
|
9bac43 |
self.stats.fields_filter = None
|
|
|
9bac43 |
|
|
|
9bac43 |
def update_pid(self, pid):
|
|
|
9bac43 |
@@ -931,7 +932,8 @@ class Tui(object):
|
|
|
9bac43 |
.format(pid, gname), curses.A_BOLD)
|
|
|
9bac43 |
else:
|
|
|
9bac43 |
self.screen.addstr(0, 0, 'kvm statistics - summary', curses.A_BOLD)
|
|
|
9bac43 |
- if self.stats.fields_filter and self.stats.fields_filter != '^[^\(]*$':
|
|
|
9bac43 |
+ if self.stats.fields_filter and self.stats.fields_filter \
|
|
|
9bac43 |
+ != DEFAULT_REGEX:
|
|
|
9bac43 |
regex = self.stats.fields_filter
|
|
|
9bac43 |
if len(regex) > MAX_REGEX_LEN:
|
|
|
9bac43 |
regex = regex[:MAX_REGEX_LEN] + '...'
|
|
|
9bac43 |
@@ -991,7 +993,7 @@ class Tui(object):
|
|
|
9bac43 |
regex = self.screen.getstr()
|
|
|
9bac43 |
curses.noecho()
|
|
|
9bac43 |
if len(regex) == 0:
|
|
|
9bac43 |
- self.stats.fields_filter = r'^[^\(]*$'
|
|
|
9bac43 |
+ self.stats.fields_filter = DEFAULT_REGEX
|
|
|
9bac43 |
self.refresh_header()
|
|
|
9bac43 |
return
|
|
|
9bac43 |
try:
|
|
|
9bac43 |
@@ -1101,6 +1103,11 @@ class Tui(object):
|
|
|
9bac43 |
sleeptime = DELAY_INITIAL
|
|
|
9bac43 |
if char == 'q':
|
|
|
9bac43 |
break
|
|
|
9bac43 |
+ if char == 'c':
|
|
|
9bac43 |
+ self.stats.fields_filter = DEFAULT_REGEX
|
|
|
9bac43 |
+ self.refresh_header(0)
|
|
|
9bac43 |
+ self.update_pid(0)
|
|
|
9bac43 |
+ sleeptime = DELAY_INITIAL
|
|
|
9bac43 |
if char == 'f':
|
|
|
9bac43 |
self.show_filter_selection()
|
|
|
9bac43 |
sleeptime = DELAY_INITIAL
|
|
|
9bac43 |
@@ -1177,6 +1184,7 @@ Requirements:
|
|
|
9bac43 |
the large number of files that are possibly opened.
|
|
|
9bac43 |
|
|
|
9bac43 |
Interactive Commands:
|
|
|
9bac43 |
+ c clear filter
|
|
|
9bac43 |
f filter by regular expression
|
|
|
9bac43 |
g filter by guest name
|
|
|
9bac43 |
p filter by PID
|
|
|
9bac43 |
diff --git a/scripts/kvm/kvm_stat.texi b/scripts/kvm/kvm_stat.texi
|
|
|
9bac43 |
index a8c1071..203d61d 100644
|
|
|
9bac43 |
--- a/scripts/kvm/kvm_stat.texi
|
|
|
9bac43 |
+++ b/scripts/kvm/kvm_stat.texi
|
|
|
9bac43 |
@@ -24,6 +24,9 @@ Use batch and logging modes for scripting purposes.
|
|
|
9bac43 |
While running in regular (interactive) mode, use any of the following keys:
|
|
|
9bac43 |
|
|
|
9bac43 |
@table @key
|
|
|
9bac43 |
+@item c
|
|
|
9bac43 |
+@kindex c
|
|
|
9bac43 |
+clear filter
|
|
|
9bac43 |
@item f
|
|
|
9bac43 |
@kindex f
|
|
|
9bac43 |
filter by regular expression
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|