progname);
fprintf(stderr, _("Options are:\n"
- "[ -C ] [ -d | -j | -p | -x ] [ -H ] [ -h ] [ -T ] [ -U ] [ -V ]\n"
+ "[ -C ] [ -d | -j | -p | -x ] [ -H ] [ -h ] [ -T | -t | -U ] [ -V ]\n"
"[ -P { <cpu> [,...] | ALL } ] [ -s [ <hh:mm:ss> ] ] [ -e [ <hh:mm:ss> ] ]\n"
"[ -- <sar_options> ]\n"));
exit(1);
/* Remove option -h */
flags &= ~S_F_HORIZONTALLY;
}
- if (!ACCEPT_TRUE_TIME(fmt[f_position]->options)) {
- /* Remove option -T */
- flags &= ~S_F_TRUE_TIME;
+ if (!ACCEPT_LOCAL_TIME(fmt[f_position]->options)) {
+ /* Remove options -T and -t */
+ flags &= ~(S_F_LOCAL_TIME + S_F_TRUE_TIME);
}
if (!ACCEPT_SEC_EPOCH(fmt[f_position]->options)) {
/* Remove option -U */
* time, based on current record's "number of seconds since the epoch" saved
* in file.
* The resulting timestamp is expressed in UTC or in local time, depending
- * on whether option -T has been used or not.
+ * on whether options -T or -t have been used or not.
*
* IN:
* @curr Index in array for current sample statistics.
* @rectime Structure where timestamp (expressed in local time or in UTC
- * depending on whether option -T has been used or not) can be
- * saved for current record.
+ * depending on whether options -T or -t have been used or not)
+ * can be saved for current record.
* @loctime Structure where timestamp (expressed in local time) can be
* saved for current record.
*
* OUT:
- * @rectime Structure where timestamp for current record has been saved.
- * @loctime Structure where timestamp for current record has been saved.
+ * @rectime Structure where timestamp for current record has been saved
+ * (in local time or in UTC depending on options used).
+ * @loctime Structure where timestamp for current record has been saved
+ * (expressed in local time). This field will be used for time
+ * comparison if options -s and/or -e have been used.
***************************************************************************
*/
void sadf_get_record_timestamp_struct(int curr, struct tm *rectime, struct tm *loctime)
*loctime = *ltm;
}
- if (!PRINT_TRUE_TIME(flags)) {
- /* Option -T not used: Display timestamp in UTC */
+ if (!PRINT_LOCAL_TIME(flags) && !PRINT_TRUE_TIME(flags)) {
+ /* Options -T and -t not used: Display timestamp in UTC */
ltm = gmtime((const time_t *) &record_hdr[curr].ust_time);
}
if (ltm) {
*rectime = *ltm;
}
+
+ if (PRINT_TRUE_TIME(flags)) {
+ /* Option -t */
+ rectime->tm_hour = record_hdr[curr].hour;
+ rectime->tm_min = record_hdr[curr].minute;
+ rectime->tm_sec = record_hdr[curr].second;
+ }
}
/*
***************************************************************************
* Set current record's timestamp strings (date and time). This timestamp is
- * expressed in UTC or in local time, depending on whether option -T has
- * been used or not.
+ * expressed in UTC or in local time, depending on whether options -T or -t
+ * have been used or not.
*
* IN:
* @curr Index in array for current sample statistics.
* @cur_time String where timestamp's time will be saved.
* @len Maximum length of timestamp strings.
* @rectime Structure with current timestamp (expressed in local time or
- * in UTC depending on whether option -T has been used or not)
- * that should be broken down in date and time strings.
+ * in UTC depending on whether options -T or -t have been used
+ * or not) that should be broken down in date and time strings.
*
* OUT:
* @cur_date Timestamp's date string.
}
else {
/*
- * If PRINT_TRUE_TIME(flags) is true (ie. option -T has been used) then
- * cur_time is expressed in local time. Else it is expressed in UTC.
+ * If options -T or -t have been used then cur_time is
+ * expressed in local time. Else it is expressed in UTC.
*/
strftime(cur_date, len, "%Y-%m-%d", rectime);
strftime(cur_time, len, "%H:%M:%S", rectime);
* @use_tm_end Set to TRUE if option -e has been used.
* @tab Number of tabulations to print.
* @rectime Structure where timestamp (expressed in local time
- * or in UTC depending on whether option -T has been
- * used or not) can be saved for current record.
+ * or in UTC depending on whether options -T/-t have
+ * been used or not) can be saved for current record.
* @loctime Structure where timestamp (expressed in local time)
* can be saved for current record.
*
if (*fmt[f_position]->f_restart) {
(*fmt[f_position]->f_restart)(&tab, F_MAIN, cur_date, cur_time,
+ !PRINT_LOCAL_TIME(flags) &&
!PRINT_TRUE_TIME(flags), &file_hdr);
}
}
* @tab Number of tabulations to print.
* @ifd Input file descriptor.
* @rectime Structure where timestamp (expressed in local time
- * or in UTC depending on whether option -T has been
- * used or not) can be saved for current record.
+ * or in UTC depending on whether options -T/-t have
+ * been used or not) can be saved for current record.
* @loctime Structure where timestamp (expressed in local time)
* can be saved for current record.
*
if (*fmt[f_position]->f_comment) {
(*fmt[f_position]->f_comment)(&tab, F_MAIN, cur_date, cur_time,
+ !PRINT_LOCAL_TIME(flags) &&
!PRINT_TRUE_TIME(flags), file_comment,
&file_hdr);
}
strcpy(temp, pre);
}
snprintf(pre, 80, "%s%s%s", temp, cur_time,
- strlen(cur_date) && !PRINT_TRUE_TIME(flags) ? " UTC" : "");
+ strlen(cur_date) && !PRINT_LOCAL_TIME(flags) &&
+ !PRINT_TRUE_TIME(flags) ? " UTC" : "");
pre[79] = '\0';
if (DISPLAY_HORIZONTALLY(flags)) {
* @act_id Activities to display.
* @cpu_nr Number of processors for current activity data file.
* @rectime Structure where timestamp (expressed in local time
- * or in UTC depending on whether option -T has been
- * used or not) can be saved for current record.
+ * or in UTC depending on whether options -T/-t have
+ * been used or not) can be saved for current record.
* @loctime Structure where timestamp (expressed in local time)
* can be saved for current record.
*
* @tab Number of tabulations to print.
* @cpu_nr Number of processors.
* @rectime Structure where timestamp (expressed in local time
- * or in UTC depending on whether option -T has been
- * used or not) can be saved for current record.
+ * or in UTC depending on whether options -T/-t have
+ * been used or not) can be saved for current record.
* @loctime Structure where timestamp (expressed in local time)
* can be saved for current record.
*
if (*fmt[f_position]->f_timestamp) {
(*fmt[f_position]->f_timestamp)(&tab, F_BEGIN, cur_date, cur_time,
+ !PRINT_LOCAL_TIME(flags) &&
!PRINT_TRUE_TIME(flags), dt);
}
if (format == F_XML_OUTPUT) {
if (*fmt[f_position]->f_timestamp) {
(*fmt[f_position]->f_timestamp)(&tab, F_MAIN, cur_date, cur_time,
+ !PRINT_LOCAL_TIME(flags) &&
!PRINT_TRUE_TIME(flags), dt);
}
}
if (*fmt[f_position]->f_timestamp) {
(*fmt[f_position]->f_timestamp)(&tab, F_END, cur_date, cur_time,
+ !PRINT_LOCAL_TIME(flags) &&
!PRINT_TRUE_TIME(flags), dt);
}
* @rtype Record type (RESTART or COMMENT).
* @ifd Input file descriptor.
* @rectime Structure where timestamp (expressed in local time
- * or in UTC depending on whether option -T has been
- * used or not) can be saved for current record.
+ * or in UTC depending on whether options -T/-t have
+ * been used or not) can be saved for current record.
* @loctime Structure where timestamp (expressed in local time)
* can be saved for current record.
***************************************************************************
if (*fmt[f_position]->f_restart) {
(*fmt[f_position]->f_restart)(NULL, F_MAIN, cur_date, cur_time,
+ !PRINT_LOCAL_TIME(flags) &&
!PRINT_TRUE_TIME(flags), &file_hdr);
}
}
if (*fmt[f_position]->f_comment) {
(*fmt[f_position]->f_comment)(NULL, F_MAIN, cur_date, cur_time,
+ !PRINT_LOCAL_TIME(flags) &&
!PRINT_TRUE_TIME(flags), file_comment,
&file_hdr);
}
* @file_actlst List of (known or unknown) activities in file.
* @cpu_nr Number of processors for current activity data file.
* @rectime Structure where timestamp (expressed in local time or in UTC
- * depending on whether option -T has been used or not) can be
- * saved for current record.
+ * depending on whether options -T/-t have been used or not) can
+ * be saved for current record.
* @loctime Structure where timestamp (expressed in local time) can be
* saved for current record.
*
* @file_magic System activity file magic header.
* @cpu_nr Number of processors for current activity data file.
* @rectime Structure where timestamp (expressed in local time or in UTC
- * depending on whether option -T has been used or not) can be
- * saved for current record.
+ * depending on whether options -T/-t have been used or not) can
+ * be saved for current record.
* @loctime Structure where timestamp (expressed in local time) can be
* saved for current record.
***************************************************************************
* @file_actlst List of (known or unknown) activities in file.
* @cpu_nr Number of processors for current activity data file.
* @rectime Structure where timestamp (expressed in local time or in UTC
- * depending on whether option -T has been used or not) can be
- * saved for current record.
+ * depending on whether options -T/-t have been used or not) can
+ * be saved for current record.
* @loctime Structure where timestamp (expressed in local time) can be
* saved for current record.
***************************************************************************
break;
case 'T':
+ flags |= S_F_LOCAL_TIME;
+ break;
+
+ case 't':
flags |= S_F_TRUE_TIME;
break;
dm_major = get_devmap_major();
}
+ /* Options -T, -t and -U are mutually exclusive */
+ if ((PRINT_LOCAL_TIME(flags) + PRINT_TRUE_TIME(flags) +
+ PRINT_SEC_EPOCH(flags)) > 1) {
+ usage(argv[0]);
+ }
+
/*
* Display all the contents of the daily data file if the count parameter
* was not set on the command line.