Hi,
I'm forwarding bug report I got during my holidays.
I can reproduce the behaviour with sysstat 7.0.0.
I haven't checked however if the attached patch is correct and works.
Best Regards,
robert
--- Begin Message ---
Package: sysstat
Version: 6.1.3
sar -s hh:mm:ss should return data after the specified time, however
it effectively skips the first record:
# sar -d |tail -n 5
14:06:08 dev8-0 0.92 0.00 18.54 20.22 0.00 0.60
0.18 0.02
14:07:08 dev8-0 0.58 0.00 13.20 22.63 0.00 0.23
0.20 0.01
14:08:08 dev8-0 1.57 0.00 36.26 23.15 0.00 1.52
0.17 0.03
14:09:08 dev8-0 0.77 0.00 17.87 23.30 0.00 0.22
0.09 0.01
Average: dev8-0 0.89 0.00 20.64 23.19 0.00 0.75
0.22 0.02
# sar -d -s 14:08:00
Linux 2.6.8-2-686 (IS-844) 20/07/06
14:08:08 DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz
await svctm %util
14:09:08 dev8-0 0.77 0.00 17.87 23.30 0.00 0.22
0.09 0.01
Average: dev8-0 0.77 0.00 17.87 23.30 0.00 0.22
0.09 0.01
# sar -d -s 14:09:00 |tail
Linux 2.6.8-2-686 (IS-844) 20/07/06
The attached patch fixes this behaviour. You will note that I've
commented out one other section as I can't see what purpose it serves.
It still works with it present FWIW.
Adrian
--
Email: [EMAIL PROTECTED] -*- GPG key available on public key servers
Debian GNU/Linux - the maintainable distribution -*- www.debian.org
Avoid working with children, animals and Microsoft "operating" systems
--- sysstat-6.1.3/sar.c 2006-05-24 14:24:07.000000000 +0100
+++ ../sysstat-6.1.3/sar.c 2006-07-20 14:06:24.000000000 +0100
@@ -882,9 +882,11 @@
set_timestamp(curr, cur_time[curr], 16);
/* Check time (2) */
+ #if 0
if (use_tm_start && (datecmp(&loc_time, &tm_start) < 0))
/* it's too soon... */
return 0;
+ #endif
/* Get interval values */
get_itv_value(&file_stats[curr], &file_stats[!curr],
@@ -1313,7 +1315,7 @@
* If this record is a DUMMY one, print it and (try to) get another one.
* We must be sure that we have real stats in file_stats[2].
*/
- do {
+ while(1) {
if (sa_fread(ifd, &file_stats[0], file_hdr.sa_st_size, SOFT_SIZE))
/* End of sa data file */
return;
@@ -1321,17 +1323,45 @@
if (file_stats[0].record_type == R_DUMMY)
write_dummy(0, tm_start.use, tm_end.use);
else {
- /*
- * Ok: previous record was not a DUMMY one.
- * So read now the extra fields.
- */
- read_extra_stats(0, ifd);
- set_loc_time(0);
+ if ((! tm_end.use) && (! tm_start.use))
+ {
+ read_extra_stats(0, ifd);
+ set_loc_time(0);
+ break;
+ }
+
+ if (tm_end.use)
+ {
+ set_loc_time(0);
+ if (datecmp(&loc_time, &tm_end) <0)
+ {
+ read_extra_stats(0, ifd);
+ break;
+ }
+ }
+
+ if (tm_start.use)
+ {
+ set_loc_time(0);
+ if (datecmp(&loc_time, &tm_start)>=0)
+ {
+ /* jump back to the start of this record,
+ * all stats are in file_stats[2] so we need
+ * to copy these to file_stats[0] */
+ if ((fpos = lseek(ifd, - file_hdr.sa_st_size, SEEK_CUR)) < 0) {
+ perror("lseek");
+ exit(2);
+ }
+ set_loc_time(2);
+ copy_structures(0, 2, USE_SA_FILE);
+ break;
+ }
+ read_extra_stats(0, ifd);
+ /* we now save this "previous" entry so we can restore it above */
+ copy_structures(2, 0, USE_SA_FILE);
+ }
}
}
- while ((file_stats[0].record_type == R_DUMMY) ||
- (tm_start.use && (datecmp(&loc_time, &tm_start) < 0)) ||
- (tm_end.use && (datecmp(&loc_time, &tm_end) >=0)));
/* Save the first stats collected. Will be used to compute the average */
copy_structures(2, 0, USE_SA_FILE);
--- End Message ---