]> granicus.if.org Git - sysstat/commitdiff
Fix incomplete sadf output when end time crosses 24H boundary
authorSebastien GODARD <sysstat@users.noreply.github.com>
Thu, 4 Sep 2014 11:53:31 +0000 (13:53 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Thu, 4 Sep 2014 11:53:31 +0000 (13:53 +0200)
Same patch as commit 19b5020 applied to sadf.

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

diff --git a/sadf.c b/sadf.c
index 690f73ef74dcf6e729dbf6fbe4da3f8e709380db..6596d875d0804a4e3e2f9de66e43a78a3b31fba6 100644 (file)
--- a/sadf.c
+++ b/sadf.c
@@ -546,6 +546,7 @@ void write_mech_stats(int curr, unsigned long dt, unsigned long long itv,
  *                     been used or not) can be saved for current record.
  * @loctime            Structure where timestamp (expressed in local time)
  *                     can be saved for current record.
+ * @reset_cd           TRUE if static cross_day variable should be reset.
  *
  * OUT:
  * @cnt                        Set to 0 to indicate that no other lines of stats
@@ -557,12 +558,21 @@ void write_mech_stats(int curr, unsigned long dt, unsigned long long itv,
  */
 int write_parsable_stats(int curr, int reset, long *cnt, int use_tm_start,
                         int use_tm_end, unsigned int act_id, __nr_t cpu_nr,
-                        struct tm *rectime, struct tm *loctime)
+                        struct tm *rectime, struct tm *loctime, int reset_cd)
 {
        unsigned long long dt, itv, g_itv;
        char cur_date[32], cur_time[32];
        static int cross_day = FALSE;
 
+       if (reset_cd) {
+               /*
+                * See note in sar.c.
+                * NB: Reseting cross_day is not needed in write_textual_stats()
+                * function (datafile is never rewinded).
+                */
+               cross_day = 0;
+       }
+
        /*
         * Check time (1).
         * For this first check, we use the time interval entered on
@@ -871,7 +881,7 @@ void rw_curr_act_stats(int ifd, off_t fpos, int *curr, long *cnt, int *eosaf,
                        char *file, struct file_magic *file_magic)
 {
        unsigned char rtype;
-       int next;
+       int next, reset_cd;
 
        if (lseek(ifd, fpos, SEEK_SET) < fpos) {
                perror("lseek");
@@ -890,6 +900,7 @@ void rw_curr_act_stats(int ifd, off_t fpos, int *curr, long *cnt, int *eosaf,
        copy_structures(act, id_seq, record_hdr, !*curr, 2);
 
        *cnt  = count;
+       reset_cd = 1;
 
        do {
                /* Display <count> lines of stats */
@@ -914,7 +925,8 @@ void rw_curr_act_stats(int ifd, off_t fpos, int *curr, long *cnt, int *eosaf,
 
                        next = write_parsable_stats(*curr, *reset, cnt,
                                                    tm_start.use, tm_end.use, act_id,
-                                                   cpu_nr, rectime, loctime);
+                                                   cpu_nr, rectime, loctime, reset_cd);
+                       reset_cd = 0;
 
                        if (next) {
                                /*