"[ -m { <keyword> [,...] | ALL } ] [ -n { <keyword> [,...] | ALL } ]\n"
"[ --dev=<dev_list> ] [ --fs=<fs_list> ] [ --iface=<iface_list> ]\n"
"[ --dec={ 0 | 1 | 2 } ] [ --help ] [ --human ] [ --sadc ]\n"
- "[ -j { ID | LABEL | PATH | UUID | ... } ]\n"
+ "[ -j { SID | ID | LABEL | PATH | UUID | ... } ]\n"
"[ -f [ <filename> ] | -o [ <filename> ] | -[0-9]+ ]\n"
"[ -i <interval> ] [ -s [ <hh:mm[:ss]> ] ] [ -e [ <hh:mm[:ss]> ] ]\n"));
exit(1);
int write_stats(int curr, int read_from_file, long *cnt, int use_tm_start,
int use_tm_end, int reset, unsigned int act_id, int reset_cd)
{
- int i;
+ int i, prev_hour;
unsigned long long itv;
static int cross_day = 0;
if (sa_get_record_timestamp_struct(flags + S_F_LOCAL_TIME, &record_hdr[!curr],
&rectime))
return 0;
+ prev_hour = rectime.tm_hour;
set_record_timestamp_string(flags, &record_hdr[!curr],
NULL, timestamp[!curr], TIMESTAMP_LEN, &rectime);
set_record_timestamp_string(flags, &record_hdr[curr],
NULL, timestamp[curr], TIMESTAMP_LEN, &rectime);
- /* Check if we are beginning a new day */
+ /*
+ * Check if we are beginning a new day.
+ * Use rectime.tm_hour and prev_hour instead of record_hdr[].hour for comparison
+ * to take into account the current timezone (hours displayed will depend on the
+ * TZ variable value).
+ */
if (use_tm_start && record_hdr[!curr].ust_time &&
(record_hdr[curr].ust_time > record_hdr[!curr].ust_time) &&
- (record_hdr[curr].hour < record_hdr[!curr].hour)) {
+ (rectime.tm_hour < prev_hour)) {
cross_day = 1;
}
}
while (*cnt && !*eosaf && (rtype != R_RESTART));
+ /*
+ * At this moment, if we had a R_RESTART record, we still haven't read
+ * the number of CPU following it (nor the possible extra structures).
+ * But in this case, we always have @cnt != 0.
+ */
+
if (davg) {
write_stats_avg(!*curr, USE_SA_FILE, act_id);
}
}
}
}
-
if (!cnt) {
- /* Go to next Linux restart, if possible */
+ /*
+ * Go to next Linux restart, if possible.
+ * Note: If we have @cnt == 0 then the last record we read was not a R_RESTART one
+ * (else we would have had @cnt != 0, i.e. we would have stopped reading previous activity
+ * because such a R_RESTART record would have been read, not because all the <count> lines
+ * had been printed).
+ * Remember @cnt is decremented only when a real line of stats have been displayed
+ * (not when a special record has been read).
+ */
do {
/* Read next record header */
eosaf = read_record_hdr(ifd, rec_hdr_tmp, &record_hdr[curr],
else if (!strcmp(argv[opt], "-I")) {
/* Parse -I option */
- if (parse_sar_I_opt(argv, &opt, act)) {
+ if (parse_sar_I_opt(argv, &opt, &flags, act)) {
usage(argv[0]);
}
}
fprintf(stderr, _("-f and -o options are mutually exclusive\n"));
exit(1);
}
+ if (USE_OPTION_A(flags)) {
+ /* Set -P ALL -I ALL if needed */
+ set_bitmaps(act, &flags);
+ }
/* Use time start or option -i only when reading stats from a file */
if ((tm_start.use || INTERVAL_SET(flags)) && !from_file[0]) {
fprintf(stderr,
#ifdef TEST
if (__unix_time) {
- sprintf(ltemp, "--unix_time=%llu", __unix_time);
+ sprintf(ltemp, "--unix_time=%ld", __unix_time);
salloc(args_idx++, ltemp);
}
#endif