Blame SOURCES/kvm-tools-kvm_stat-add-Total-column.patch

4a2fec
From 4f80c9081b411684efbd2e3caff57e7a261d71e7 Mon Sep 17 00:00:00 2001
4a2fec
From: David Hildenbrand <david@redhat.com>
4a2fec
Date: Tue, 17 Oct 2017 19:15:43 +0200
4a2fec
Subject: [PATCH 38/69] tools/kvm_stat: add '%Total' column
4a2fec
MIME-Version: 1.0
4a2fec
Content-Type: text/plain; charset=UTF-8
4a2fec
Content-Transfer-Encoding: 8bit
4a2fec
4a2fec
RH-Author: David Hildenbrand <david@redhat.com>
4a2fec
Message-id: <20171017191605.2378-18-david@redhat.com>
4a2fec
Patchwork-id: 77328
4a2fec
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 17/39] tools/kvm_stat: add '%Total' column
4a2fec
Bugzilla: 1497137
4a2fec
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4a2fec
4a2fec
Upstream-status: linux.git e55fe3ccccc1efb8f20c99728c8863424ae9ee4a
4a2fec
4a2fec
commit e55fe3ccccc1efb8f20c99728c8863424ae9ee4a
4a2fec
Author: Stefan Raspl <raspl@linux.vnet.ibm.com>
4a2fec
Date:   Fri Mar 10 13:40:16 2017 +0100
4a2fec
4a2fec
    tools/kvm_stat: add '%Total' column
4a2fec
4a2fec
    Add column '%Total' next to 'Total' for easier comparison of numbers between
4a2fec
    hosts.
4a2fec
4a2fec
    Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
4a2fec
    Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
4a2fec
    Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
4a2fec
4a2fec
Signed-off-by: David Hildenbrand <david@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 scripts/kvm/kvm_stat | 9 ++++++++-
4a2fec
 1 file changed, 8 insertions(+), 1 deletion(-)
4a2fec
4a2fec
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
4a2fec
index f8c48f8..8f74ed8 100755
4a2fec
--- a/scripts/kvm/kvm_stat
4a2fec
+++ b/scripts/kvm/kvm_stat
4a2fec
@@ -973,7 +973,9 @@ class Tui(object):
4a2fec
         self.screen.addstr(2, 1, 'Event')
4a2fec
         self.screen.addstr(2, 1 + LABEL_WIDTH + NUMBER_WIDTH -
4a2fec
                            len('Total'), 'Total')
4a2fec
-        self.screen.addstr(2, 1 + LABEL_WIDTH + NUMBER_WIDTH + 8 -
4a2fec
+        self.screen.addstr(2, 1 + LABEL_WIDTH + NUMBER_WIDTH + 7 -
4a2fec
+                           len('%Total'), '%Total')
4a2fec
+        self.screen.addstr(2, 1 + LABEL_WIDTH + NUMBER_WIDTH + 7 + 8 -
4a2fec
                            len('Current'), 'Current')
4a2fec
         self.screen.addstr(4, 1, 'Collecting data...')
4a2fec
         self.screen.refresh()
4a2fec
@@ -989,6 +991,9 @@ class Tui(object):
4a2fec
                 return (-stats[x][1], -stats[x][0])
4a2fec
             else:
4a2fec
                 return (0, -stats[x][0])
4a2fec
+        total = 0.
4a2fec
+        for val in stats.values():
4a2fec
+            total += val[0]
4a2fec
         for key in sorted(stats.keys(), key=sortkey):
4a2fec
 
4a2fec
             if row >= self.screen.getmaxyx()[0]:
4a2fec
@@ -1001,6 +1006,8 @@ class Tui(object):
4a2fec
             col += LABEL_WIDTH
4a2fec
             self.screen.addstr(row, col, '%10d' % (values[0],))
4a2fec
             col += NUMBER_WIDTH
4a2fec
+            self.screen.addstr(row, col, '%7.1f' % (values[0] * 100 / total,))
4a2fec
+            col += 7
4a2fec
             if values[1] is not None:
4a2fec
                 self.screen.addstr(row, col, '%8d' % (values[1] / sleeptime,))
4a2fec
             row += 1
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec