From: Stefan Raspl <raspl@linux.vnet.ibm.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com, frankja@linux.vnet.ibm.com
Subject: [PATCH v1 15/19] tools/kvm_stat: add new interactive command 's'
Date: Wed, 7 Jun 2017 21:08:39 +0200 [thread overview]
Message-ID: <20170607190843.76869-16-raspl@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170607190843.76869-1-raspl@linux.vnet.ibm.com>
Add new command 's' to modify the update interval. Limited to a maximum of
25.5 sec and a minimum of 0.1 sec, since curses cannot handle longer
and shorter delays respectively.
Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
---
tools/kvm/kvm_stat/kvm_stat | 55 +++++++++++++++++++++++++++++++++++------
tools/kvm/kvm_stat/kvm_stat.txt | 2 ++
2 files changed, 49 insertions(+), 8 deletions(-)
diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index 6838de38ecb5..1276b88937c0 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -844,8 +844,7 @@ class Stats(object):
self.values[key] = (newval, newdelta)
return self.values
-DELAY_INITIAL = 0.25
-DELAY_REGULAR = 3.0
+DELAY_DEFAULT = 3.0
MAX_GUEST_NAME_LEN = 48
MAX_REGEX_LEN = 44
DEFAULT_REGEX = r'^[^\(]*$'
@@ -856,6 +855,8 @@ class Tui(object):
def __init__(self, stats):
self.stats = stats
self.screen = None
+ self._delay_initial = 0.25
+ self._delay_regular = DELAY_DEFAULT
def __enter__(self):
"""Initialises curses for later use. Based on curses.wrapper
@@ -1027,6 +1028,7 @@ class Tui(object):
' p filter by PID',
' q quit',
' r reset stats',
+ ' s set update interval',
' x toggle reporting of stats for individual child trace'
' events',
'Any other key refreshes statistics immediately')
@@ -1106,10 +1108,41 @@ class Tui(object):
self.refresh_header(pid)
self.update_pid(pid)
break
-
except ValueError:
msg = '"' + str(pid) + '": Not a valid pid'
+ def show_set_update_interval(self):
+ """Draws update interval selection mask."""
+ msg = ''
+ while True:
+ self.screen.erase()
+ self.screen.addstr(0, 0, 'Set update interval (defaults to %fs).' %
+ DELAY_DEFAULT, curses.A_BOLD)
+ self.screen.addstr(4, 0, msg)
+ self.screen.addstr(2, 0, 'Change delay from %.1fs to ' %
+ self._delay_regular)
+ curses.echo()
+ val = self.screen.getstr()
+ curses.noecho()
+
+ try:
+ if len(val) > 0:
+ delay = float(val)
+ if delay < 0.1:
+ msg = '"' + str(val) + '": Value must be >=0.1'
+ continue
+ if delay > 25.5:
+ msg = '"' + str(val) + '": Value must be <=25.5'
+ continue
+ else:
+ delay = DELAY_DEFAULT
+ self._delay_regular = delay
+ break
+
+ except ValueError:
+ msg = '"' + str(val) + '": Invalid value'
+ self.refresh_header()
+
def show_vm_selection_by_guest_name(self):
"""Draws guest selection mask.
@@ -1156,14 +1189,14 @@ class Tui(object):
def show_stats(self):
"""Refreshes the screen and processes user input."""
- sleeptime = DELAY_INITIAL
+ sleeptime = self._delay_initial
self.refresh_header()
start = 0.0 # result based on init value never appears on screen
while True:
self.refresh_body(time.time() - start)
curses.halfdelay(int(sleeptime * 10))
start = time.time()
- sleeptime = DELAY_REGULAR
+ sleeptime = self._delay_regular
try:
char = self.screen.getkey()
if char == 'c':
@@ -1174,23 +1207,28 @@ class Tui(object):
curses.curs_set(1)
self.show_filter_selection()
curses.curs_set(0)
- sleeptime = DELAY_INITIAL
+ sleeptime = self._delay_initial
if char == 'g':
curses.curs_set(1)
self.show_vm_selection_by_guest_name()
curses.curs_set(0)
- sleeptime = DELAY_INITIAL
+ sleeptime = self._delay_initial
if char == 'h':
self.show_help_interactive()
if char == 'p':
curses.curs_set(1)
self.show_vm_selection_by_pid()
curses.curs_set(0)
- sleeptime = DELAY_INITIAL
+ sleeptime = self._delay_initial
if char == 'q':
break
if char == 'r':
self.stats.reset()
+ if char == 's':
+ curses.curs_set(1)
+ self.show_set_update_interval()
+ curses.curs_set(0)
+ sleeptime = self._delay_initial
if char == 'x':
self.update_drilldown()
except KeyboardInterrupt:
@@ -1267,6 +1305,7 @@ Interactive Commands:
p filter by PID
q quit
r reset stats
+ s set update interval
x toggle reporting of stats for individual child trace events
Press any other key to refresh statistics immediately.
"""
diff --git a/tools/kvm/kvm_stat/kvm_stat.txt b/tools/kvm/kvm_stat/kvm_stat.txt
index 2bad6f22183b..cc019b09e0f5 100644
--- a/tools/kvm/kvm_stat/kvm_stat.txt
+++ b/tools/kvm/kvm_stat/kvm_stat.txt
@@ -43,6 +43,8 @@ INTERACTIVE COMMANDS
*r*:: reset stats
+*s*:: set update interval
+
*x*:: toggle reporting of stats for child trace events
Press any other key to refresh statistics immediately.
--
2.11.2
next prev parent reply other threads:[~2017-06-07 19:09 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 19:08 [PATCH v1 00/19] tools/kvm_stat: More misc patches Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 01/19] tools/kvm_stat: fix typo Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 02/19] tools/kvm_stat: fix event counts display for interrupted intervals Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 03/19] tools/kvm_stat: fix undue use of initial sleeptime Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 04/19] tools/kvm_stat: remove unnecessary header redraws Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 05/19] tools/kvm_stat: simplify line print logic Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 06/19] tools/kvm_stat: removed unused function Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 07/19] tools/kvm_stat: remove extra statement Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 08/19] tools/kvm_stat: simplify initializers Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 09/19] tools/kvm_stat: move functions to corresponding classes Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 10/19] tools/kvm_stat: show cursor in selection screens Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 11/19] tools/kvm_stat: display message indicating lack of events Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 12/19] tools/kvm_stat: make heading look a bit more like 'top' Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 13/19] tools/kvm_stat: rename 'Current' column to 'CurAvg/s' Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 14/19] tools/kvm_stat: add new interactive command 'h' Stefan Raspl
2017-06-08 16:19 ` Paolo Bonzini
2017-06-20 9:10 ` Stefan Raspl
2017-06-20 12:34 ` Paolo Bonzini
2017-06-07 19:08 ` Stefan Raspl [this message]
2017-06-07 19:08 ` [PATCH v1 16/19] tools/kvm_stat: add new interactive command 't' Stefan Raspl
2017-06-08 16:21 ` Paolo Bonzini
2017-06-20 9:10 ` Stefan Raspl
2017-06-20 12:34 ` Paolo Bonzini
2017-06-20 13:09 ` Stefan Raspl
2017-06-20 13:17 ` Paolo Bonzini
2017-06-20 14:17 ` Stefan Raspl
2017-06-20 14:47 ` Paolo Bonzini
2017-06-21 6:54 ` Stefan Raspl
2017-06-21 10:37 ` Paolo Bonzini
2017-06-22 7:46 ` Stefan Raspl
2017-06-22 7:52 ` Paolo Bonzini
2017-06-22 8:51 ` Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 17/19] tools/kvm_stat: add new interactive command 'o' Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 18/19] tools/kvm_stat: add new interactive command 'b' Stefan Raspl
2017-06-08 16:24 ` Paolo Bonzini
2017-06-20 9:10 ` Stefan Raspl
2017-06-20 12:33 ` Paolo Bonzini
2017-06-20 13:07 ` Stefan Raspl
2017-06-20 13:10 ` Paolo Bonzini
2017-06-20 14:41 ` Stefan Raspl
2017-06-20 14:47 ` Paolo Bonzini
2017-06-21 4:51 ` Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 19/19] tools/kvm_stat: display guest list in pid/guest selection screens Stefan Raspl
2017-06-08 16:25 ` [PATCH v1 00/19] tools/kvm_stat: More misc patches Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170607190843.76869-16-raspl@linux.vnet.ibm.com \
--to=raspl@linux.vnet.ibm.com \
--cc=frankja@linux.vnet.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).