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

9bac43
From 4f80c9081b411684efbd2e3caff57e7a261d71e7 Mon Sep 17 00:00:00 2001
9bac43
From: David Hildenbrand <david@redhat.com>
9bac43
Date: Tue, 17 Oct 2017 19:15:43 +0200
9bac43
Subject: [PATCH 38/69] tools/kvm_stat: add '%Total' column
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-18-david@redhat.com>
9bac43
Patchwork-id: 77328
9bac43
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 17/39] tools/kvm_stat: add '%Total' column
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 e55fe3ccccc1efb8f20c99728c8863424ae9ee4a
9bac43
9bac43
commit e55fe3ccccc1efb8f20c99728c8863424ae9ee4a
9bac43
Author: Stefan Raspl <raspl@linux.vnet.ibm.com>
9bac43
Date:   Fri Mar 10 13:40:16 2017 +0100
9bac43
9bac43
    tools/kvm_stat: add '%Total' column
9bac43
9bac43
    Add column '%Total' next to 'Total' for easier comparison of numbers between
9bac43
    hosts.
9bac43
9bac43
    Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
9bac43
    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 | 9 ++++++++-
9bac43
 1 file changed, 8 insertions(+), 1 deletion(-)
9bac43
9bac43
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
9bac43
index f8c48f8..8f74ed8 100755
9bac43
--- a/scripts/kvm/kvm_stat
9bac43
+++ b/scripts/kvm/kvm_stat
9bac43
@@ -973,7 +973,9 @@ class Tui(object):
9bac43
         self.screen.addstr(2, 1, 'Event')
9bac43
         self.screen.addstr(2, 1 + LABEL_WIDTH + NUMBER_WIDTH -
9bac43
                            len('Total'), 'Total')
9bac43
-        self.screen.addstr(2, 1 + LABEL_WIDTH + NUMBER_WIDTH + 8 -
9bac43
+        self.screen.addstr(2, 1 + LABEL_WIDTH + NUMBER_WIDTH + 7 -
9bac43
+                           len('%Total'), '%Total')
9bac43
+        self.screen.addstr(2, 1 + LABEL_WIDTH + NUMBER_WIDTH + 7 + 8 -
9bac43
                            len('Current'), 'Current')
9bac43
         self.screen.addstr(4, 1, 'Collecting data...')
9bac43
         self.screen.refresh()
9bac43
@@ -989,6 +991,9 @@ class Tui(object):
9bac43
                 return (-stats[x][1], -stats[x][0])
9bac43
             else:
9bac43
                 return (0, -stats[x][0])
9bac43
+        total = 0.
9bac43
+        for val in stats.values():
9bac43
+            total += val[0]
9bac43
         for key in sorted(stats.keys(), key=sortkey):
9bac43
 
9bac43
             if row >= self.screen.getmaxyx()[0]:
9bac43
@@ -1001,6 +1006,8 @@ class Tui(object):
9bac43
             col += LABEL_WIDTH
9bac43
             self.screen.addstr(row, col, '%10d' % (values[0],))
9bac43
             col += NUMBER_WIDTH
9bac43
+            self.screen.addstr(row, col, '%7.1f' % (values[0] * 100 / total,))
9bac43
+            col += 7
9bac43
             if values[1] is not None:
9bac43
                 self.screen.addstr(row, col, '%8d' % (values[1] / sleeptime,))
9bac43
             row += 1
9bac43
-- 
9bac43
1.8.3.1
9bac43