File sysstat-12.1.6-iostat-y-option.diff of Package sysstat.22705

From 7910965d1a982ee48fab5cf18d8bd07a7d809980 Mon Sep 17 00:00:00 2001
From: Sebastien GODARD <sysstat@users.noreply.github.com>
Date: Fri, 21 Jun 2019 17:48:44 +0200
Subject: [PATCH] iostat: Fix wrong CPU stats displayed with option -y

CPU statistics written for the first sample was wrong when option -y was
used. This was because the interval of time used was that since system
startup whereas it should have been the interval of time since last
sample (which is not displayed with option -y).

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
---
 iostat.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Index: sysstat-12.0.2/iostat.c
===================================================================
--- sysstat-12.0.2.orig/iostat.c
+++ sysstat-12.0.2/iostat.c
@@ -930,16 +930,6 @@ void write_cpu_stat(int curr, int tab)
 {
 	unsigned long long deltot_jiffies;
 
-	/*
-	 * Compute the total number of jiffies spent by all processors.
-	 * NB: Don't add cpu_guest/cpu_guest_nice because cpu_user/cpu_nice
-	 * already include them.
-	 */
-	tot_jiffies[curr] = st_cpu[curr]->cpu_user + st_cpu[curr]->cpu_nice +
-			    st_cpu[curr]->cpu_sys + st_cpu[curr]->cpu_idle +
-			    st_cpu[curr]->cpu_iowait + st_cpu[curr]->cpu_hardirq +
-			    st_cpu[curr]->cpu_steal + st_cpu[curr]->cpu_softirq;
-
 	/* Total number of jiffies spent on the interval */
 	deltot_jiffies = get_interval(tot_jiffies[!curr], tot_jiffies[curr]);
 
@@ -1648,6 +1638,16 @@ void rw_io_stat_loop(long int count, str
 		/* Read stats for CPU "all" */
 		read_stat_cpu(st_cpu[curr], 1);
 
+		/*
+		 * Compute the total number of jiffies spent by all processors.
+		 * NB: Don't add cpu_guest/cpu_guest_nice because cpu_user/cpu_nice
+		 * already include them.
+		 */
+		tot_jiffies[curr] = st_cpu[curr]->cpu_user + st_cpu[curr]->cpu_nice +
+				    st_cpu[curr]->cpu_sys + st_cpu[curr]->cpu_idle +
+				    st_cpu[curr]->cpu_iowait + st_cpu[curr]->cpu_hardirq +
+				    st_cpu[curr]->cpu_steal + st_cpu[curr]->cpu_softirq;
+
 		if (dlist_idx) {
 			/*
 			 * A device or partition name was explicitly entered
openSUSE Build Service is sponsored by