vmstat: print guest time

This commit is contained in:
zhoujie 2023-07-13 11:35:31 +08:00
parent f90bdf7c4e
commit a3c3677f4d
2 changed files with 77 additions and 3 deletions

View File

@ -0,0 +1,70 @@
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

View File

@ -1,6 +1,6 @@
Name: procps-ng Name: procps-ng
Version: 4.0.2 Version: 4.0.2
Release: 8 Release: 9
Summary: Utilities that provide system information. Summary: Utilities that provide system information.
License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+
URL: https://sourceforge.net/projects/procps-ng/ URL: https://sourceforge.net/projects/procps-ng/
@ -20,6 +20,7 @@ Patch8: backport-pmap-Increase-memory-allocation-failure-judgment.patch
Patch9: backport-top-added-guest-tics-when-multiple-cpus-were-merged.patch Patch9: backport-top-added-guest-tics-when-multiple-cpus-were-merged.patch
Patch10: backport-library-restore-the-proper-main-thread-tics-valuation.patch Patch10: backport-library-restore-the-proper-main-thread-tics-valuation.patch
Patch11: backport-vmstat-Update-memory-statistics.patch Patch11: backport-vmstat-Update-memory-statistics.patch
Patch12: backport-vmstat-Print-guest-time.patch
BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel
@ -102,6 +103,9 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
%{_mandir}/man* %{_mandir}/man*
%changelog %changelog
* Thu Jul 13 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-9
- vmstat: print guest time
* Wed Jul 12 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-8 * Wed Jul 12 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-8
- vmstat: Update memory statistics - vmstat: Update memory statistics
@ -109,10 +113,10 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
- library: restore the proper main thread tics valuation - library: restore the proper main thread tics valuation
* Wed Jun 28 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-6 * Wed Jun 28 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-6
- top: added guest tics when multiple cpus were merged - top: added guest tics when multiple cpus were merged
* Mon Jun 26 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-5 * Mon Jun 26 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-5
- pamp: increase memory allocation failure judgment - pmap: increase memory allocation failure judgment
* Tue Jun 13 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-4 * Tue Jun 13 2023 zhoujie <zhoujie133@huawei.com> - 4.0.2-4
- top: first time display delay - top: first time display delay