diff options
author | Sanskriti Sharma <sansharm@redhat.com> | 2023-01-18 16:54:25 +1100 |
---|---|---|
committer | Craig Small <csmall@dropbear.xyz> | 2023-01-18 16:56:24 +1100 |
commit | 68e2c0fc53c78217d5fb3bfbb6f73a6e5d0e39bd (patch) | |
tree | ba52df9bb632c52b430c0fdd1c9a3070f36ad978 | |
parent | 8a65a304e00e39011e84c0b4e75d5ed3c53db53b (diff) | |
download | procps-ng-68e2c0fc53c78217d5fb3bfbb6f73a6e5d0e39bd.tar.gz |
vmstat: Fixed initial si,so,bi,bo,in & cs values
In the default display option, the first line of stats output in the
above mentioned columns was incorrect.
References:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=668580
procps-ng/procps!74
procps-ng/procps#15
Signed-off-by: Craig Small <csmall@dropbear.xyz>
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/vmstat.c | 19 |
2 files changed, 14 insertions, 7 deletions
@@ -7,6 +7,8 @@ procps-ng-NEXT * skill: Match on -p again Debian #1025915 * top: E/P-core toggle ('5' key) added to help * vmstat: Referesh memory statistics Debian #1027963 + * vmstat: Fix initial si,so,bi,bo,in & cs values issue #15 + Debian #668580 * w: Add --pids option merge #159 * watch: Pass through beep issue #104 * watch: -r option to not re-exec on SIGWINCH merge #125 diff --git a/src/vmstat.c b/src/vmstat.c index d076cf2..b4bcb8f 100644 --- a/src/vmstat.c +++ b/src/vmstat.c @@ -365,6 +365,7 @@ static void new_format(void) struct tm *tm_ptr; time_t the_time; char timebuf[32]; + double uptime; struct vmstat_info *vm_info = NULL; struct stat_info *stat_info = NULL; struct stat_stack *stat_stack; @@ -380,6 +381,10 @@ static void new_format(void) xerrx(EXIT_FAILURE, _("Unable to create system stat structure")); if (procps_meminfo_new(&mem_info) < 0) xerrx(EXIT_FAILURE, _("Unable to create meminfo structure")); + if (procps_uptime(&uptime, NULL) < 0) + xerr(EXIT_FAILURE, _("Unable to get uptime")); + if (0.0 == uptime) + uptime = 1.0; new_header(); pgpgin[tog] = VMSTAT_GET(vm_info, VMSTAT_PGPGIN, ul_int); @@ -425,12 +430,12 @@ static void new_format(void) unitConvert(MEMv(mem_FREE)), unitConvert((a_option?MEMv(mem_INA):MEMv(mem_BUF))), unitConvert((a_option?MEMv(mem_ACT):MEMv(mem_CAC))), - (unsigned)( (unitConvert(VMSTAT_GET(vm_info, VMSTAT_PSWPIN, ul_int) * kb_per_page) * hz + divo2) / Div ), - (unsigned)( (unitConvert(VMSTAT_GET(vm_info, VMSTAT_PSWPOUT, ul_int) * kb_per_page) * hz + divo2) / Div ), - (unsigned)( (VMSTAT_GET(vm_info, VMSTAT_PGPGIN, ul_int) * hz + divo2) / Div ), - (unsigned)( (VMSTAT_GET(vm_info, VMSTAT_PGPGOUT, ul_int) * hz + divo2) / Div ), - (unsigned)( (SYSv(stat_INT) * hz + divo2) / Div ), - (unsigned)( (SYSv(stat_CTX) * hz + divo2) / Div ), + (unsigned)( unitConvert(VMSTAT_GET(vm_info, VMSTAT_PSWPIN, ul_int) * kb_per_page) / uptime ), + (unsigned)( unitConvert(VMSTAT_GET(vm_info, VMSTAT_PSWPOUT, ul_int) * kb_per_page) / uptime ), + (unsigned)( VMSTAT_GET(vm_info, VMSTAT_PGPGIN, ul_int) / uptime ), + (unsigned)( VMSTAT_GET(vm_info, VMSTAT_PGPGOUT, ul_int) / uptime ), + (unsigned)( SYSv(stat_INT) / uptime ), + (unsigned)( SYSv(stat_CTX) / Div ), (unsigned)( (100*cpu_use + divo2) / Div ), (unsigned)( (100*cpu_sys + divo2) / Div ), (unsigned)( (100*cpu_idl + divo2) / Div ), @@ -764,7 +769,7 @@ static void slabformat (void) slab_AOBJS, slab_OBJS, slab_OSIZE, slab_OPS, slab_NAME }; if (procps_slabinfo_new(&slab_info) < 0) - xerrx(EXIT_FAILURE, _("Unable to create slabinfo structure")); + xerr(EXIT_FAILURE, _("Unable to create slabinfo structure")); if (!moreheaders) slabheader(); |