From: Sebastien GODARD Date: Fri, 26 Apr 2019 08:20:43 +0000 (+0200) Subject: sadc: Fix bad number of CPU displayed in a LINUX RESTART message X-Git-Tag: v12.1.5~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e45e0909b574881342c87fb252c7cd5954e76c2;p=sysstat sadc: Fix bad number of CPU displayed in a LINUX RESTART message 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 --- diff --git a/sadc.c b/sadc.c index 87d7332..557a8e7 100644 --- 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.