]> granicus.if.org Git - sysstat/commitdiff
sadc: Fix bad number of CPU displayed in a LINUX RESTART message
authorSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 26 Apr 2019 08:20:43 +0000 (10:20 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 26 Apr 2019 08:20:43 +0000 (10:20 +0200)
sadc didn't take into account properly a different number of CPU
When appending data to an existing file. This was because the number of
CPU recorded with the restart message was overwritten with that
originally saved in the file.
This patch fixes the problem.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
sadc.c

diff --git a/sadc.c b/sadc.c
index 87d7332c36168d2d50642188a4654bfaed448398..557a8e77071e1027b90d9598c0ab5dc33c54cea8 100644 (file)
--- a/sadc.c
+++ b/sadc.c
@@ -954,8 +954,11 @@ void open_ofile(int *ofd, char ofile[], int restart_mark)
                 * Since we are appending data to a file, set @nr_ini to the value of the file.
                 * Stats saved in file will all be 0 for that activity if no items exist on
                 * the machine.
+                * NB: We must preserve the value read for A_CPU when a LINUX RESTART is inserted.
                 */
-               act[p]->nr_ini = file_act[i].nr;
+               if (!ALWAYS_COUNT_ITEMS(act[p]->options) || !act[p]->nr_ini) {
+                       act[p]->nr_ini = file_act[i].nr;
+               }
 
                /*
                 * Force number of sub-items to that of the file, and reallocate structures.