]> granicus.if.org Git - sysstat/commitdiff
sadc.c: Fix number of items passed to sar
authorSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 27 Dec 2017 13:24:11 +0000 (14:24 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 27 Dec 2017 13:24:11 +0000 (14:24 +0100)
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 <sysstat@users.noreply.github.com>
sadc.c

diff --git a/sadc.c b/sadc.c
index 5a32e7266c8b24316b64d1bafa2c32ad340348d9..c96d134362d8ad85dfbc329dc62e9fe92d9429a8 100644 (file)
--- 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;