From f4eeff0b26a2c48552f8ed843bea95bf97437d2a Mon Sep 17 00:00:00 2001
From: Craig Small <csmall@dropbear.xyz>
Date: Tue, 11 Jul 2023 19:16:15 +1000
Subject: [PATCH] vmstat: Print guest time

Guest time was removed from User time but not printed. This meant
that if guest time was non-zero then the CPU numbers did not add
up to 100%

References:
 !191
 !113
 commit 2461bb5bc17ee4bc01b142b5bba2c5d87578285c

Signed-off-by: Craig Small <csmall@dropbear.xyz>
---
 src/vmstat.c                     | 6 +++---
 testsuite/vmstat.test/vmstat.exp | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/vmstat.c b/src/vmstat.c
index acb7b80..68d356c 100644
--- a/src/vmstat.c
+++ b/src/vmstat.c
@@ -254,13 +254,13 @@ static void new_header(void)
      * that follow (marked with max x chars) might not work,
      * unless manual page is translated as well.  */
     const char *header =
-        _("procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----");
+        _("procs -----------memory---------- ---swap-- -----io---- -system-- -------cpu-------");
     const char *wide_header =
         _("--procs-- -----------------------memory---------------------- ---swap-- -----io---- -system-- ----------cpu----------");
     const char *timestamp_header = _(" -----timestamp-----");
 
     const char format[] =
-        "%2s %2s %6s %6s %6s %6s %4s %4s %5s %5s %4s %4s %2s %2s %2s %2s %2s";
+        "%2s %2s %6s %6s %6s %6s %4s %4s %5s %5s %4s %4s %2s %2s %2s %2s %2s %2s";
     const char wide_format[] =
         "%4s %4s %12s %12s %12s %12s %4s %4s %5s %5s %4s %4s %3s %3s %3s %3s %3s %3s";
 
@@ -349,7 +349,7 @@ static void new_format(void)
 #define MEMv(E) MEMINFO_VAL(E, ul_int, mem_stack, mem_info)
 #define DSYSv(E) STAT_VAL(E, s_int, stat_stack, stat_info)
     const char format[] =
-        "%2lu %2lu %6lu %6lu %6lu %6lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u";
+        "%2lu %2lu %6lu %6lu %6lu %6lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u %2u";
     const char wide_format[] =
         "%4lu %4lu %12lu %12lu %12lu %12lu %4u %4u %5u %5u %4u %4u %3u %3u %3u %3u %3u %3u";
 
diff --git a/testsuite/vmstat.test/vmstat.exp b/testsuite/vmstat.test/vmstat.exp
index 1cd13a1..48d0b0f 100644
--- a/testsuite/vmstat.test/vmstat.exp
+++ b/testsuite/vmstat.test/vmstat.exp
@@ -12,11 +12,11 @@ if { [ file readable "/proc/vmstat" ] == 0 } {
 } else {
     set test "vmstat with no arguments"
     spawn $vmstat
-    expect_pass "$test" "^procs\[ -\]+memory\[ -\]+swap\[ -\]+io\[ -\]+system\[ -\]+cpu\[ -\]+\\s*r\\s+b\\s+swpd\\s+free\\s+buff\\s+cache\\s+si\\s+so\\s+bi\\s+bo\\s+in\\s+cs us sy id wa st\\s*\(\\s+\\d+\){17}\\s*$"
+    expect_pass "$test" "^procs\[ -\]+memory\[ -\]+swap\[ -\]+io\[ -\]+system\[ -\]+cpu\[ -\]+\\s*r\\s+b\\s+swpd\\s+free\\s+buff\\s+cache\\s+si\\s+so\\s+bi\\s+bo\\s+in\\s+cs us sy id wa st gu\\s*\(\\s+\\d+\){18}\\s*$"
 
     set test "vmstat with -a flag"
     spawn $vmstat -a
-    expect_pass "$test" "^procs\[ -\]+memory\[ -\]+swap\[ -\]+io\[ -\]+system\[ -\]+cpu\[ -\]+\\s*r\\s+b\\s+swpd\\s+free\\s+inact\\s+active\\s+si\\s+so\\s+bi\\s+bo\\s+in\\s+cs us sy id wa st\\s*\(\\s+\\d+\){17}\\s*$"
+    expect_pass "$test" "^procs\[ -\]+memory\[ -\]+swap\[ -\]+io\[ -\]+system\[ -\]+cpu\[ -\]+\\s*r\\s+b\\s+swpd\\s+free\\s+inact\\s+active\\s+si\\s+so\\s+bi\\s+bo\\s+in\\s+cs us sy id wa st gu\\s*\(\\s+\\d+\){18}\\s*$"
 
     set test "vmstat fork option"
     spawn $vmstat -f
-- 
2.33.0

