From 76fdb89ea7c74123e42d6c09cbbfab2fde10eeaa Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Wed, 27 Dec 2017 14:24:11 +0100 Subject: [PATCH] sadc.c: Fix number of items passed to sar When appending data to a file, the number of items passed by sadc to sar cannot be 0 for any activity. Signed-off-by: Sebastien GODARD --- sadc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sadc.c b/sadc.c index 5a32e72..c96d134 100644 --- a/sadc.c +++ b/sadc.c @@ -949,6 +949,15 @@ void open_ofile(int *ofd, char ofile[], int restart_mark) /* Save activity sequence */ id_seq[i] = file_act[i].id; act[p]->options |= AO_COLLECTED; + + /* + * sar doesn't expect a number of items equal to 0. + * Yet @nr_ini may be 0 if no items have been found on current machine. + * 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. + */ + act[p]->nr_ini = file_act[i].nr; } return; -- 2.40.0