char minute; /* locale of the datafile creator) for first */
char second; /* sample */
struct file_header *file_hdr; /* Pointer on file header structure */
+ char my_tzname[TZNAME_LEN]; /* Current timezone */
};
/* Structure used when displaying SVG header */
* This function displays the report header
* (data displayed once at the beginning of the report).
*/
- __printf_funct_t (*f_header) (void *, int, char *, struct file_magic *, struct file_header *,
- struct activity * [], unsigned int [], struct file_activity *);
+ __printf_funct_t (*f_header) (void *, int, char *, char *, struct file_magic *,
+ struct file_header *, struct activity * [], unsigned int [],
+ struct file_activity *);
/*
* This function defines the statistics part of the report.
* Used only with textual (XML-like) reports and PCP archives.
* This function defines the timestamp part of the report.
* Used only with textual (XML-like) reports, PCP archives and RAW output format.
*/
- __tm_funct_t (*f_timestamp) (void *, int, char *, char *, unsigned long long,
+ __tm_funct_t (*f_timestamp) (void *, int, char *, char *, char *, unsigned long long,
struct record_header *, struct file_header *, unsigned int);
/*
* This function displays the restart messages.
*/
- __printf_funct_t (*f_restart) (int *, int, char *, char *,
+ __printf_funct_t (*f_restart) (int *, int, char *, char *, char *,
struct file_header *, struct record_header *);
/*
* This function displays the comments.
*/
- __printf_funct_t (*f_comment) (int *, int, char *, char *, char *,
+ __printf_funct_t (*f_comment) (int *, int, char *, char *, char *, char *,
struct file_header *, struct record_header *);
/*
* This is the main function used to display all the statistics for current format.
void print_report_hdr
(uint64_t, struct tm *, struct file_header *);
void print_sar_comment
- (int *, int, char *, char *, char *, struct file_header *,
+ (int *, int, char *, char *, char *, char *, struct file_header *,
struct record_header *);
__printf_funct_t print_sar_restart
- (int *, int, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
int print_special_record
(struct record_header *, uint64_t, struct tstamp *, struct tstamp *,
- int, int, struct tm *, char *, int, struct file_magic *,
+ int, int, struct tm *, char *, int, char *, struct file_magic *,
struct file_header *, struct activity * [], struct report_format *, int, int);
int read_file_stat_bunch
(struct activity * [], int, int, int, struct file_activity *, int, int,
* be saved for current record.
* @file Name of file being read.
* @tab Number of tabulations to print.
+ * @my_tz Current timezone.
* @file_magic file_magic structure filled with file magic header data.
* @file_hdr System activity file standard header.
* @act Array of activities.
*/
int print_special_record(struct record_header *record_hdr, uint64_t l_flags,
struct tstamp *tm_start, struct tstamp *tm_end, int rtype, int ifd,
- struct tm *rectime, char *file, int tab,
+ struct tm *rectime, char *file, int tab, char *my_tz,
struct file_magic *file_magic, struct file_header *file_hdr,
struct activity *act[], struct report_format *ofmt,
int endian_mismatch, int arch_64)
return 0;
if (*ofmt->f_restart) {
- (*ofmt->f_restart)(&tab, F_MAIN, cur_date, cur_time, file_hdr, record_hdr);
+ (*ofmt->f_restart)(&tab, F_MAIN, cur_date, cur_time, my_tz, file_hdr, record_hdr);
}
}
else if (rtype == R_COMMENT) {
return 0;
if (*ofmt->f_comment) {
- (*ofmt->f_comment)(&tab, F_MAIN, cur_date, cur_time,
+ (*ofmt->f_comment)(&tab, F_MAIN, cur_date, cur_time, my_tz,
file_comment, file_hdr, record_hdr);
}
}
void int_handler(int n) { return; }
#endif
+extern char *tzname[2];
+
long interval = -1, count = 0;
/* TRUE if data read from file don't match current machine's endianness */
struct tstamp tm_start, tm_end;
char *args[MAX_ARGV_NR];
+/* Current timezone */
+char my_tzname[TZNAME_LEN];
+
extern struct activity *act[];
extern struct report_format *fmt[];
else {
/* Display COMMENT record */
print_special_record(&record_hdr[curr], flags, &tm_start, &tm_end,
- *rtype, ifd, rectime, file, tab,
+ *rtype, ifd, rectime, file, tab, my_tzname,
file_magic, &file_hdr, act, fmt[f_position],
endian_mismatch, arch_64);
}
else {
/* Display RESTART record */
print_special_record(&record_hdr[curr], flags, &tm_start, &tm_end,
- *rtype, ifd, rectime, file, tab,
+ *rtype, ifd, rectime, file, tab, my_tzname,
file_magic, &file_hdr, act, fmt[f_position],
endian_mismatch, arch_64);
}
cur_date, cur_time, TIMESTAMP_LEN, rectime);
if (*fmt[f_position]->f_timestamp) {
- pre = (char *) (*fmt[f_position]->f_timestamp)(parm, F_BEGIN, cur_date, cur_time, dt,
- &record_hdr[curr], &file_hdr, flags);
+ pre = (char *) (*fmt[f_position]->f_timestamp)(parm, F_BEGIN, cur_date, cur_time,
+ my_tzname, dt, &record_hdr[curr],
+ &file_hdr, flags);
}
/* Display statistics */
if (IS_SELECTED(act[i]->options) && (act[i]->nr[curr] > 0)) {
if (*fmt[f_position]->f_timestamp) {
- (*fmt[f_position]->f_timestamp)(tab, F_MAIN, cur_date, cur_time,
+ (*fmt[f_position]->f_timestamp)(tab, F_MAIN, cur_date, cur_time, NULL,
dt, &record_hdr[curr],
&file_hdr, flags);
}
}
if (*fmt[f_position]->f_timestamp) {
- (*fmt[f_position]->f_timestamp)(parm, F_END, cur_date, cur_time, dt,
+ (*fmt[f_position]->f_timestamp)(parm, F_END, cur_date, cur_time, NULL, dt,
&record_hdr[curr], &file_hdr, flags);
}
parm.hour = record_hdr[2].hour;
parm.minute = record_hdr[2].minute;
parm.second = record_hdr[2].second;
+ strcpy(parm.my_tzname, my_tzname);
*cnt = count;
reset_cd = 1;
/* Print header (eg. XML file header) */
if (*fmt[f_position]->f_header) {
- (*fmt[f_position]->f_header)(&tab, F_BEGIN, pcparchive, file_magic,
+ (*fmt[f_position]->f_header)(&tab, F_BEGIN, pcparchive, my_tzname, file_magic,
&file_hdr, act, id_seq, file_actlst);
}
/* RESTART and COMMENTS records will be immediately processed */
if (*fmt[f_position]->f_restart) {
- (*fmt[f_position]->f_restart)(&tab, F_BEGIN, NULL, NULL, &file_hdr, NULL);
+ (*fmt[f_position]->f_restart)(&tab, F_BEGIN, NULL, NULL, NULL,
+ &file_hdr, NULL);
}
if (DISPLAY_COMMENT(flags) && (*fmt[f_position]->f_comment)) {
- (*fmt[f_position]->f_comment)(&tab, F_BEGIN, NULL, NULL, NULL,
+ (*fmt[f_position]->f_comment)(&tab, F_BEGIN, NULL, NULL, NULL, NULL,
&file_hdr, NULL);
}
}
* Display possible trailing data then terminate.
*/
if (*fmt[f_position]->f_restart) {
- (*fmt[f_position]->f_restart)(&tab, F_END, NULL, NULL, &file_hdr, NULL);
+ (*fmt[f_position]->f_restart)(&tab, F_END, NULL, NULL, NULL,
+ &file_hdr, NULL);
}
if (DISPLAY_COMMENT(flags) && (*fmt[f_position]->f_comment)) {
- (*fmt[f_position]->f_comment)(&tab, F_END, NULL, NULL, NULL,
+ (*fmt[f_position]->f_comment)(&tab, F_END, NULL, NULL, NULL, NULL,
&file_hdr, NULL);
}
goto terminate;
/* Process now RESTART entries to display restart messages */
if (*fmt[f_position]->f_restart) {
- (*fmt[f_position]->f_restart)(&tab, F_BEGIN, NULL, NULL, &file_hdr, NULL);
+ (*fmt[f_position]->f_restart)(&tab, F_BEGIN, NULL, NULL, NULL, &file_hdr, NULL);
}
do {
while (!eosaf);
if (*fmt[f_position]->f_restart) {
- (*fmt[f_position]->f_restart)(&tab, F_END, NULL, NULL, &file_hdr, NULL);
+ (*fmt[f_position]->f_restart)(&tab, F_END, NULL, NULL, NULL, &file_hdr, NULL);
}
/* Rewind file */
/* Last, process COMMENT entries to display comments */
if (DISPLAY_COMMENT(flags)) {
if (*fmt[f_position]->f_comment) {
- (*fmt[f_position]->f_comment)(&tab, F_BEGIN, NULL, NULL, NULL,
+ (*fmt[f_position]->f_comment)(&tab, F_BEGIN, NULL, NULL, NULL, NULL,
&file_hdr, NULL);
}
do {
while (!eosaf);
if (*fmt[f_position]->f_comment) {
- (*fmt[f_position]->f_comment)(&tab, F_END, NULL, NULL, NULL,
+ (*fmt[f_position]->f_comment)(&tab, F_END, NULL, NULL, NULL, NULL,
&file_hdr, NULL);
}
}
terminate:
/* Print header trailer */
if (*fmt[f_position]->f_header) {
- (*fmt[f_position]->f_header)(&tab, F_END, pcparchive, file_magic,
+ (*fmt[f_position]->f_header)(&tab, F_END, pcparchive, my_tzname, file_magic,
&file_hdr, act, id_seq, file_actlst);
}
}
*/
if (!eosaf && (record_hdr[curr].record_type == R_RESTART)) {
print_special_record(&record_hdr[curr], flags, &tm_start, &tm_end,
- R_RESTART, ifd, rectime, file, 0,
+ R_RESTART, ifd, rectime, file, 0, my_tzname,
file_magic, &file_hdr, act, fmt[f_position],
endian_mismatch, arch_64);
}
/* Print SVG header */
if (*fmt[f_position]->f_header) {
- (*fmt[f_position]->f_header)(&parm, F_BEGIN + F_MAIN, file, file_magic,
+ (*fmt[f_position]->f_header)(&parm, F_BEGIN + F_MAIN, file, NULL, file_magic,
&file_hdr, act, id_seq, file_actlst);
}
close_svg:
/* Print SVG trailer */
if (*fmt[f_position]->f_header) {
- (*fmt[f_position]->f_header)(&parm, F_END, file, file_magic,
+ (*fmt[f_position]->f_header)(&parm, F_END, file, NULL, file_magic,
&file_hdr, act, id_seq, file_actlst);
}
}
dfile = pcparchive;
}
/* Display only data file header then exit */
- (*fmt[f_position]->f_header)(&tab, F_BEGIN + F_END, dfile, &file_magic,
- &file_hdr, act, id_seq, file_actlst);
+ (*fmt[f_position]->f_header)(&tab, F_BEGIN + F_END, dfile, my_tzname,
+ &file_magic, &file_hdr, act, id_seq,
+ file_actlst);
}
exit(0);
}
usage(argv[0]);
}
+ /* Get timezone */
+ if (PRINT_LOCAL_TIME(flags)) {
+ tzset();
+ strncpy(my_tzname, tzname[0], TZNAME_LEN);
+ my_tzname[TZNAME_LEN - 1] = '\0';
+ }
+
/*
* Display all the contents of the daily data file if the count parameter
* was not set on the command line.
* Prototypes used to display restart messages
*/
__printf_funct_t print_db_restart
- (int *, int, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
__printf_funct_t print_ppc_restart
- (int *, int, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
__printf_funct_t print_xml_restart
- (int *, int, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
__printf_funct_t print_json_restart
- (int *, int, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
__printf_funct_t print_raw_restart
- (int *, int, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
__printf_funct_t print_pcp_restart
- (int *, int, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
/*
* Prototypes used to display comments
*/
__printf_funct_t print_db_comment
- (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, char *, struct file_header *, struct record_header *);
__printf_funct_t print_ppc_comment
- (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, char *, struct file_header *, struct record_header *);
__printf_funct_t print_xml_comment
- (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, char *, struct file_header *, struct record_header *);
__printf_funct_t print_json_comment
- (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, char *, struct file_header *, struct record_header *);
__printf_funct_t print_raw_comment
- (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, char *, struct file_header *, struct record_header *);
__printf_funct_t print_pcp_comment
- (int *, int, char *, char *, char *, struct file_header *, struct record_header *);
+ (int *, int, char *, char *, char *, char *, struct file_header *, struct record_header *);
/*
* Prototypes used to display the statistics part of the report
* Prototypes used to display the timestamp part of the report
*/
__tm_funct_t print_db_timestamp
- (void *, int, char *, char *, unsigned long long,
+ (void *, int, char *, char *, char *, unsigned long long,
struct record_header *, struct file_header *, unsigned int);
__tm_funct_t print_ppc_timestamp
- (void *, int, char *, char *, unsigned long long,
+ (void *, int, char *, char *, char *, unsigned long long,
struct record_header *, struct file_header *, unsigned int);
__tm_funct_t print_xml_timestamp
- (void *, int, char *, char *, unsigned long long,
+ (void *, int, char *, char *, char *, unsigned long long,
struct record_header *, struct file_header *, unsigned int);
__tm_funct_t print_json_timestamp
- (void *, int, char *, char *, unsigned long long,
+ (void *, int, char *, char *, char *, unsigned long long,
struct record_header *, struct file_header *, unsigned int);
__tm_funct_t print_raw_timestamp
- (void *, int, char *, char *, unsigned long long,
+ (void *, int, char *, char *, char *, unsigned long long,
struct record_header *, struct file_header *, unsigned int);
__tm_funct_t print_pcp_timestamp
- (void *, int, char *, char *, unsigned long long,
+ (void *, int, char *, char *, char *, unsigned long long,
struct record_header *, struct file_header *, unsigned int);
/*
* Prototypes used to display the report header
*/
__printf_funct_t print_xml_header
- (void *, int, char *, struct file_magic *, struct file_header *,
+ (void *, int, char *, char *, struct file_magic *, struct file_header *,
struct activity * [], unsigned int [], struct file_activity *);
__printf_funct_t print_json_header
- (void *, int, char *, struct file_magic *, struct file_header *,
+ (void *, int, char *, char *, struct file_magic *, struct file_header *,
struct activity * [], unsigned int [], struct file_activity *);
__printf_funct_t print_hdr_header
- (void *, int, char *, struct file_magic *, struct file_header *,
+ (void *, int, char *, char *, struct file_magic *, struct file_header *,
struct activity * [], unsigned int [], struct file_activity *);
__printf_funct_t print_svg_header
- (void *, int, char *, struct file_magic *, struct file_header *,
+ (void *, int, char *, char *, struct file_magic *, struct file_header *,
struct activity * [], unsigned int [], struct file_activity *);
__printf_funct_t print_pcp_header
- (void *, int, char *, struct file_magic *, struct file_header *,
+ (void *, int, char *, char *, struct file_magic *, struct file_header *,
struct activity * [], unsigned int [], struct file_activity *);
/*
* IN:
* @cur_date Date string of current restart message.
* @cur_time Time string of current restart message.
+ * @my_tz Current timezone.
* @sep Character used as separator.
* @file_hdr System activity file standard header.
***************************************************************************
*/
-void print_dbppc_restart(char *cur_date, char *cur_time, char sep,
+void print_dbppc_restart(char *cur_date, char *cur_time, char *my_tz, char sep,
struct file_header *file_hdr)
{
printf("%s%c-1%c", file_hdr->sa_nodename, sep, sep);
printf("%s ", cur_date);
}
printf("%s", cur_time);
- if (strlen(cur_date) && !PRINT_LOCAL_TIME(flags)) {
- printf(" %s", PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname : "UTC");
+ if (strlen(cur_date)) {
+ printf(" %s", PRINT_LOCAL_TIME(flags) ? my_tz
+ : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname
+ : "UTC"));
}
printf("%cLINUX-RESTART\t(%d CPU)\n",
sep, file_hdr->sa_cpu_nr > 1 ? file_hdr->sa_cpu_nr - 1 : 1);
* @action Action expected from current function.
* @cur_date Date string of current restart message.
* @cur_time Time string of current restart message.
+ * @my_tz Current timezone.
* @file_hdr System activity file standard header.
* @record_hdr Current record header (unused here).
***************************************************************************
*/
-__printf_funct_t print_db_restart(int *tab, int action, char *cur_date,
- char *cur_time, struct file_header *file_hdr,
+__printf_funct_t print_db_restart(int *tab, int action, char *cur_date, char *cur_time,
+ char *my_tz, struct file_header *file_hdr,
struct record_header *record_hdr)
{
/* Actions F_BEGIN and F_END ignored */
if (action == F_MAIN) {
- print_dbppc_restart(cur_date, cur_time, ';', file_hdr);
+ print_dbppc_restart(cur_date, cur_time, my_tz, ';', file_hdr);
}
}
* @action Action expected from current function.
* @cur_date Date string of current restart message.
* @cur_time Time string of current restart message.
+ * @my_tz Current timezone.
* @file_hdr System activity file standard header.
* @record_hdr Current record header (unused here).
***************************************************************************
*/
-__printf_funct_t print_ppc_restart(int *tab, int action, char *cur_date,
- char *cur_time, struct file_header *file_hdr,
+__printf_funct_t print_ppc_restart(int *tab, int action, char *cur_date, char *cur_time,
+ char *my_tz, struct file_header *file_hdr,
struct record_header *record_hdr)
{
/* Actions F_BEGIN and F_END ignored */
if (action == F_MAIN) {
- print_dbppc_restart(cur_date, cur_time, '\t', file_hdr);
+ print_dbppc_restart(cur_date, cur_time, my_tz, '\t', file_hdr);
}
}
* @action Action expected from current function.
* @cur_date Date string of current restart message.
* @cur_time Time string of current restart message.
+ * @my_tz Current timezone (unused here).
* @file_hdr System activity file standard header.
* @record_hdr Current record header (unused here).
*
* @tab Number of tabulations.
***************************************************************************
*/
-__printf_funct_t print_xml_restart(int *tab, int action, char *cur_date,
- char *cur_time, struct file_header *file_hdr,
+__printf_funct_t print_xml_restart(int *tab, int action, char *cur_date, char *cur_time,
+ char *my_tz, struct file_header *file_hdr,
struct record_header *record_hdr)
{
if (action & F_BEGIN) {
xprintf((*tab)++, "<restarts>");
}
if (action & F_MAIN) {
- xprintf(*tab, "<boot date=\"%s\" time=\"%s\" utc=\"%d\" cpu_count=\"%d\"/>",
+ xprintf(*tab, "<boot date=\"%s\" time=\"%s\" tz=\"%s\" cpu_count=\"%d\"/>",
cur_date, cur_time,
- !PRINT_LOCAL_TIME(flags) && !PRINT_TRUE_TIME(flags) ? 1 : 0,
+ PRINT_LOCAL_TIME(flags) ? my_tz
+ : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname
+ : "UTC"),
file_hdr->sa_cpu_nr > 1 ? file_hdr->sa_cpu_nr - 1 : 1);
}
if (action & F_END) {
* @action Action expected from current function.
* @cur_date Date string of current restart message.
* @cur_time Time string of current restart message.
+ * @my_tz Current timezone (unused here).
* @file_hdr System activity file standard header.
* @record_hdr Current record header (unused here).
*
* @tab Number of tabulations.
***************************************************************************
*/
-__printf_funct_t print_json_restart(int *tab, int action, char *cur_date,
- char *cur_time, struct file_header *file_hdr,
+__printf_funct_t print_json_restart(int *tab, int action, char *cur_date, char *cur_time,
+ char *my_tz, struct file_header *file_hdr,
struct record_header *record_hdr)
{
static int sep = FALSE;
printf(",\n");
}
xprintf((*tab)++, "{");
- xprintf(*tab, "\"boot\": {\"date\": \"%s\", \"time\": \"%s\", \"utc\": %d, \"cpu_count\": %d}",
+ xprintf(*tab, "\"boot\": {\"date\": \"%s\", \"time\": \"%s\", \"tz\": \"%s\", \"cpu_count\": %d}",
cur_date, cur_time,
- !PRINT_LOCAL_TIME(flags) && !PRINT_TRUE_TIME(flags) ? 1 : 0,
+ PRINT_LOCAL_TIME(flags) ? my_tz
+ : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname
+ : "UTC"),
file_hdr->sa_cpu_nr > 1 ? file_hdr->sa_cpu_nr - 1 : 1);
xprintf0(--(*tab), "}");
sep = TRUE;
* @action Action expected from current function.
* @cur_date Date string of current restart message.
* @cur_time Time string of current restart message.
+ * @my_tz Current timezone.
* @file_hdr System activity file standard header.
* @record_hdr Current record header (unused here).
***************************************************************************
*/
-__printf_funct_t print_raw_restart(int *tab, int action, char *cur_date,
- char *cur_time, struct file_header *file_hdr,
+__printf_funct_t print_raw_restart(int *tab, int action, char *cur_date, char *cur_time,
+ char *my_tz, struct file_header *file_hdr,
struct record_header *record_hdr)
{
/* Actions F_BEGIN and F_END ignored */
if (action == F_MAIN) {
printf("%s", cur_time);
- if (strlen(cur_date) && !PRINT_LOCAL_TIME(flags)) {
- printf(" %s", PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname : "UTC");
+ if (strlen(cur_date)) {
+ printf(" %s", PRINT_LOCAL_TIME(flags) ? my_tz
+ : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname
+ : "UTC"));
}
printf("; LINUX-RESTART (%d CPU)\n",
file_hdr->sa_cpu_nr > 1 ? file_hdr->sa_cpu_nr - 1 : 1);
* @action Action expected from current function.
* @cur_date Date string of current restart message (unused here).
* @cur_time Time string of current restart message (unused here).
+ * @my_tz Current timezone (unused here).
* @file_hdr System activity file standard header.
* @record_hdr Current record header.
***************************************************************************
*/
__printf_funct_t print_pcp_restart(int *tab, int action, char *cur_date, char *cur_time,
- struct file_header *file_hdr,
+ char *my_tz, struct file_header *file_hdr,
struct record_header *record_hdr)
{
#ifdef HAVE_PCP
* IN:
* @cur_date Date string of current restart message.
* @cur_time Time string of current restart message.
+ * @my_tz Current timezone.
* @comment Comment to display.
* @sep Character used as separator.
* @file_hdr System activity file standard header.
***************************************************************************
*/
-void print_dbppc_comment(char *cur_date, char *cur_time, char *comment,
+void print_dbppc_comment(char *cur_date, char *cur_time, char *my_tz, char *comment,
char sep, struct file_header *file_hdr)
{
printf("%s%c-1%c", file_hdr->sa_nodename, sep, sep);
printf("%s ", cur_date);
}
printf("%s", cur_time);
- if (strlen(cur_date) && !PRINT_LOCAL_TIME(flags)) {
- printf(" %s", PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname : "UTC");
+ if (strlen(cur_date)) {
+ printf(" %s", PRINT_LOCAL_TIME(flags) ? my_tz
+ : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname
+ : "UTC"));
}
printf("%cCOM %s\n", sep, comment);
}
* @action Action expected from current function.
* @cur_date Date string of current restart message.
* @cur_time Time string of current restart message.
+ * @my_tz Current timezone.
* @comment Comment to display.
* @file_hdr System activity file standard header.
* @record_hdr Current record header (unused here).
***************************************************************************
*/
__printf_funct_t print_db_comment(int *tab, int action, char *cur_date, char *cur_time,
- char *comment, struct file_header *file_hdr,
+ char *my_tz, char *comment, struct file_header *file_hdr,
struct record_header *record_hdr)
{
/* Actions F_BEGIN and F_END ignored */
if (action & F_MAIN) {
- print_dbppc_comment(cur_date, cur_time, comment, ';', file_hdr);
+ print_dbppc_comment(cur_date, cur_time, my_tz, comment, ';', file_hdr);
}
}
* @action Action expected from current function.
* @cur_date Date string of current restart message.
* @cur_time Time string of current restart message.
+ * @my_tz Current timezone.
* @comment Comment to display.
* @file_hdr System activity file standard header.
* @record_hdr Current record header (unused here).
***************************************************************************
*/
__printf_funct_t print_ppc_comment(int *tab, int action, char *cur_date, char *cur_time,
- char *comment, struct file_header *file_hdr,
+ char *my_tz, char *comment, struct file_header *file_hdr,
struct record_header *record_hdr)
{
/* Actions F_BEGIN and F_END ignored */
if (action & F_MAIN) {
- print_dbppc_comment(cur_date, cur_time, comment, '\t', file_hdr);
+ print_dbppc_comment(cur_date, cur_time, my_tz, comment, '\t', file_hdr);
}
}
* @action Action expected from current function.
* @cur_date Date string of current comment.
* @cur_time Time string of current comment.
+ * @my_tz Current timezone.
* @comment Comment to display.
* @file_hdr System activity file standard header (unused here).
* @record_hdr Current record header (unused here).
***************************************************************************
*/
__printf_funct_t print_xml_comment(int *tab, int action, char *cur_date, char *cur_time,
- char *comment, struct file_header *file_hdr,
+ char *my_tz, char *comment, struct file_header *file_hdr,
struct record_header *record_hdr)
{
if (action & F_BEGIN) {
xprintf((*tab)++, "<comments>");
}
if (action & F_MAIN) {
- xprintf(*tab, "<comment date=\"%s\" time=\"%s\" utc=\"%d\" com=\"%s\"/>",
+ xprintf(*tab, "<comment date=\"%s\" time=\"%s\" tz=\"%s\" com=\"%s\"/>",
cur_date, cur_time,
- !PRINT_LOCAL_TIME(flags) && !PRINT_TRUE_TIME(flags) ? 1 : 0,
+ PRINT_LOCAL_TIME(flags) ? my_tz
+ : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname
+ : "UTC"),
comment);
}
if (action & F_END) {
* @action Action expected from current function.
* @cur_date Date string of current comment.
* @cur_time Time string of current comment.
+ * @my_tz Current timezone.
* @comment Comment to display.
* @file_hdr System activity file standard header (unused here).
* @record_hdr Current record header (unused here).
***************************************************************************
*/
__printf_funct_t print_json_comment(int *tab, int action, char *cur_date, char *cur_time,
- char *comment, struct file_header *file_hdr,
+ char *my_tz, char *comment, struct file_header *file_hdr,
struct record_header *record_hdr)
{
static int sep = FALSE;
xprintf((*tab)++, "{");
xprintf(*tab,
"\"comment\": {\"date\": \"%s\", \"time\": \"%s\", "
- "\"utc\": %d, \"com\": \"%s\"}",
+ "\"tz\": \"%s\", \"com\": \"%s\"}",
cur_date, cur_time,
- !PRINT_LOCAL_TIME(flags) && !PRINT_TRUE_TIME(flags) ? 1 : 0,
+ PRINT_LOCAL_TIME(flags) ? my_tz
+ : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname
+ : "UTC"),
comment);
xprintf0(--(*tab), "}");
sep = TRUE;
* @action Action expected from current function.
* @cur_date Date string of current restart message.
* @cur_time Time string of current restart message.
+ * @my_tz Current timezone.
* @comment Comment to display.
* @file_hdr System activity file standard header (unused here).
* @record_hdr Current record header (unused here).
***************************************************************************
*/
__printf_funct_t print_raw_comment(int *tab, int action, char *cur_date, char *cur_time,
- char *comment, struct file_header *file_hdr,
+ char *my_tz, char *comment, struct file_header *file_hdr,
struct record_header *record_hdr)
{
/* Actions F_BEGIN and F_END ignored */
if (action & F_MAIN) {
printf("%s", cur_time);
- if (strlen(cur_date) && !PRINT_LOCAL_TIME(flags)) {
- printf(" %s", PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname : "UTC");
+ if (strlen(cur_date)) {
+ printf(" %s",
+ PRINT_LOCAL_TIME(flags) ? my_tz
+ : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname
+ : "UTC"));
}
printf("; COM %s\n", comment);
}
* @action Action expected from current function.
* @cur_date Date string of current restart message (unused here).
* @cur_time Time string of current restart message (unused here).
- * @utc True if @cur_time is expressed in UTC (unused here).
+ * @my_tz Current timezone (unused here).
* @comment Comment to display.
* @file_hdr System activity file standard header (unused here).
* @record_hdr Current record header.
***************************************************************************
*/
__printf_funct_t print_pcp_comment(int *tab, int action, char *cur_date, char *cur_time,
- char *comment, struct file_header *file_hdr,
+ char *my_tz, char *comment, struct file_header *file_hdr,
struct record_header *record_hdr)
{
#ifdef HAVE_PCP
* @file_hdr System activity file standard header.
* @cur_date Date string of current record.
* @cur_time Time string of current record.
+ * @my_tz Current timezone.
* @itv Interval of time with preceding record.
*
* RETURNS:
***************************************************************************
*/
char *print_dbppc_timestamp(int fmt, struct file_header *file_hdr, char *cur_date,
- char *cur_time, unsigned long long itv)
+ char *cur_time, char *my_tz, unsigned long long itv)
{
int isdb = (fmt == F_DB_OUTPUT);
static char pre[512];
char temp1[128], temp2[256];
- int sep = !PRINT_LOCAL_TIME(flags);
/* This substring appears on every output line, preformat it here */
snprintf(temp1, sizeof(temp1), "%s%s%lld%s",
else {
strcpy(temp2, temp1);
}
- snprintf(pre, sizeof(pre), "%s%s%s%s", temp2, cur_time, sep ? " " : "",
- strlen(cur_date) && !PRINT_LOCAL_TIME(flags) ?
- (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname : "UTC") : "");
+ snprintf(pre, sizeof(pre), "%s%s %s", temp2, cur_time,
+ strlen(cur_date) ? (PRINT_LOCAL_TIME(flags) ? my_tz
+ : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname
+ : "UTC"))
+ : "");
pre[sizeof(pre) - 1] = '\0';
if (DISPLAY_HORIZONTALLY(flags)) {
* @action Action expected from current function.
* @cur_date Date string of current record.
* @cur_time Time string of current record.
+ * @my_tz Current timezone.
* @itv Interval of time with preceding record.
* @record_hdr Record header for current sample (unused here).
* @file_hdr System activity file standard header.
***************************************************************************
*/
__tm_funct_t print_ppc_timestamp(void *parm, int action, char *cur_date,
- char *cur_time, unsigned long long itv,
+ char *cur_time, char * my_tz, unsigned long long itv,
struct record_header *record_hdr,
struct file_header *file_hdr, unsigned int flags)
{
if (action & F_BEGIN) {
- return print_dbppc_timestamp(F_PPC_OUTPUT, file_hdr, cur_date, cur_time, itv);
+ return print_dbppc_timestamp(F_PPC_OUTPUT, file_hdr, cur_date, cur_time,
+ my_tz, itv);
}
return NULL;
* @action Action expected from current function.
* @cur_date Date string of current record.
* @cur_time Time string of current record.
+ * @my_tz Current timezone.
* @itv Interval of time with preceding record.
* @record_hdr Record header for current sample (unused here).
* @file_hdr System activity file standard header.
***************************************************************************
*/
__tm_funct_t print_db_timestamp(void *parm, int action, char *cur_date,
- char *cur_time, unsigned long long itv,
+ char *cur_time, char *my_tz, unsigned long long itv,
struct record_header *record_hdr,
struct file_header *file_hdr, unsigned int flags)
{
if (action & F_BEGIN) {
- return print_dbppc_timestamp(F_DB_OUTPUT, file_hdr, cur_date, cur_time, itv);
+ return print_dbppc_timestamp(F_DB_OUTPUT, file_hdr, cur_date, cur_time,
+ my_tz, itv);
}
if (action & F_END) {
if (DISPLAY_HORIZONTALLY(flags)) {
* @action Action expected from current function.
* @cur_date Date string of current comment.
* @cur_time Time string of current comment.
+ * @my_tz Current timezone.
* @itv Interval of time with preceding record.
* @record_hdr Record header for current sample (unused here).
* @file_hdr System activity file standard header (unused here).
***************************************************************************
*/
__tm_funct_t print_xml_timestamp(void *parm, int action, char *cur_date,
- char *cur_time, unsigned long long itv,
+ char *cur_time, char *my_tz, unsigned long long itv,
struct record_header *record_hdr,
struct file_header *file_hdr, unsigned int flags)
{
- int utc = !PRINT_LOCAL_TIME(flags) && !PRINT_TRUE_TIME(flags);
int *tab = (int *) parm;
if (action & F_BEGIN) {
- xprintf((*tab)++, "<timestamp date=\"%s\" time=\"%s\" utc=\"%d\" interval=\"%llu\">",
- cur_date, cur_time, utc ? 1 : 0, itv);
+ xprintf((*tab)++, "<timestamp date=\"%s\" time=\"%s\" tz=\"%s\" interval=\"%llu\">",
+ cur_date, cur_time,
+ PRINT_LOCAL_TIME(flags) ? my_tz
+ : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname
+ : "UTC"),
+ itv);
}
if (action & F_END) {
xprintf(--(*tab), "</timestamp>");
* @action Action expected from current function.
* @cur_date Date string of current comment.
* @cur_time Time string of current comment.
+ * @my_tz Current timezone.
* @itv Interval of time with preceding record.
* @record_hdr Record header for current sample (unused here).
* @file_hdr System activity file standard header (unused here).
***************************************************************************
*/
__tm_funct_t print_json_timestamp(void *parm, int action, char *cur_date,
- char *cur_time, unsigned long long itv,
+ char *cur_time, char *my_tz, unsigned long long itv,
struct record_header *record_hdr,
struct file_header *file_hdr, unsigned int flags)
{
- int utc = !PRINT_LOCAL_TIME(flags) && !PRINT_TRUE_TIME(flags);
int *tab = (int *) parm;
if (action & F_BEGIN) {
xprintf0(*tab,
"\"timestamp\": {\"date\": \"%s\", \"time\": \"%s\", "
- "\"utc\": %d, \"interval\": %llu}",
- cur_date, cur_time, utc ? 1 : 0, itv);
+ "\"tz\": \"%s\", \"interval\": %llu}",
+ cur_date, cur_time,
+ PRINT_LOCAL_TIME(flags) ? my_tz
+ : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname
+ : "UTC"),
+ itv);
}
if (action & F_MAIN) {
printf(",\n");
* @action Action expected from current function.
* @cur_date Date string of current record.
* @cur_time Time string of current record.
+ * @my_tz Current timezone.
* @itv Interval of time with preceding record (unused here).
* @record_hdr Record header for current sample (unused here).
* @file_hdr System activity file standard header (unused here).
***************************************************************************
*/
__tm_funct_t print_raw_timestamp(void *parm, int action, char *cur_date,
- char *cur_time, unsigned long long itv,
+ char *cur_time, char *my_tz, unsigned long long itv,
struct record_header *record_hdr,
struct file_header *file_hdr, unsigned int flags)
{
- int sep = !PRINT_LOCAL_TIME(flags);
static char pre[80];
if (action & F_BEGIN) {
- snprintf(pre, sizeof(pre), "%s%s%s", cur_time, sep ? " " : "",
- strlen(cur_date) && !PRINT_LOCAL_TIME(flags) ?
- (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname : "UTC") : "");
+ snprintf(pre, sizeof(pre), "%s %s", cur_time,
+ strlen(cur_date) ? (PRINT_LOCAL_TIME(flags) ? my_tz
+ : (PRINT_TRUE_TIME(flags) ? file_hdr->sa_tzname
+ : "UTC"))
+ : "");
pre[sizeof(pre) - 1] = '\0';
return pre;
}
* @action Action expected from current function.
* @cur_date Date string of current record (unused here).
* @cur_time Time string of current record (unused here).
+ * @my_tz Current timezone (unused here).
* @itv Interval of time with preceding record (unused here).
* @record_hdr Record header for current sample.
* @file_hdr System activity file standard header (unused here).
***************************************************************************
*/
__tm_funct_t print_pcp_timestamp(void *parm, int action, char *cur_date,
- char *cur_time, unsigned long long itv,
+ char *cur_time, char *my_tz, unsigned long long itv,
struct record_header *record_hdr,
struct file_header *file_hdr, unsigned int flags)
{
* @parm Specific parameter. Here: number of tabulations.
* @action Action expected from current function.
* @dfile Unused here (PCP archive file).
+ * @my_tz Current timezone (unused here).
* @file_magic System activity file magic header.
* @file_hdr System activity file standard header.
* @act Array of activities (unused here).
* @parm Number of tabulations.
***************************************************************************
*/
-__printf_funct_t print_xml_header(void *parm, int action, char *dfile,
+__printf_funct_t print_xml_header(void *parm, int action, char *dfile, char *my_tz,
struct file_magic *file_magic,
struct file_header *file_hdr,
struct activity *act[], unsigned int id_seq[],
* @parm Specific parameter. Here: number of tabulations.
* @action Action expected from current function.
* @dfile Unused here (PCP archive file).
+ * @my_tz Current timezone (unused here).
* @file_magic System activity file magic header.
* @file_hdr System activity file standard header.
* @act Array of activities (unused here).
* @parm Number of tabulations.
***************************************************************************
*/
-__printf_funct_t print_json_header(void *parm, int action, char *dfile,
+__printf_funct_t print_json_header(void *parm, int action, char *dfile, char *my_tz,
struct file_magic *file_magic,
struct file_header *file_hdr,
struct activity *act[], unsigned int id_seq[],
* @parm Specific parameter (unused here).
* @action Action expected from current function.
* @dfile Name of system activity data file (unused here).
+ * @my_tz Current timezone (unused here).
* @file_magic System activity file magic header.
* @file_hdr System activity file standard header.
* @act Array of activities.
* @file_actlst List of (known or unknown) activities in file.
***************************************************************************
*/
-__printf_funct_t print_hdr_header(void *parm, int action, char *dfile,
+__printf_funct_t print_hdr_header(void *parm, int action, char *dfile, char *my_tz,
struct file_magic *file_magic,
struct file_header *file_hdr,
struct activity *act[], unsigned int id_seq[],
* max number of views on a single row (@views_per_row).
* @action Action expected from current function.
* @dfile Name of system activity data file (unused here).
+ * @my_tz Current timezone (unused here).
* @file_magic System activity file magic header (unused here).
* @file_hdr System activity file standard header.
* @act Array of activities (unused here).
* @file_actlst List of (known or unknown) activities in file (unused here).
***************************************************************************
*/
-__printf_funct_t print_svg_header(void *parm, int action, char *dfile,
+__printf_funct_t print_svg_header(void *parm, int action, char *dfile, char *my_tz,
struct file_magic *file_magic,
struct file_header *file_hdr,
struct activity *act[], unsigned int id_seq[],
* @parm Specific parameter (unused here).
* @action Action expected from current function.
* @dfile Name of PCP archive file.
+ * @my_tz Current timezone.
* @file_magic System activity file magic header (unused here).
* @file_hdr System activity file standard header (unused here).
* @act Array of activities (unused here).
* @file_actlst List of (known or unknown) activities in file (unused here).
***************************************************************************
*/
-__printf_funct_t print_pcp_header(void *parm, int action, char *dfile,
+__printf_funct_t print_pcp_header(void *parm, int action, char *dfile, char *my_tz,
struct file_magic *file_magic,
struct file_header *file_hdr,
struct activity *act[], unsigned int id_seq[],
pmiStart(dfile, FALSE);
if (PRINT_LOCAL_TIME(flags)) {
- pmiSetTimezone(file_hdr->sa_tzname);
+ pmiSetTimezone(my_tz);
}
else {
pmiSetTimezone("UTC");
if (action & F_END) {
if (action & F_BEGIN) {
- /* Only the header data will be written to PCP archive */
+ /* Only the header data will be written to PCP archive (option -H) */
if (!PRINT_LOCAL_TIME(flags)) {
/* Convert a time_t value from local time to UTC */
if (gmtime_r(&t, &lrectime)) {
* @action Action expected from current function (unused here).
* @cur_date Date string of current restart message (unused here).
* @cur_time Time string of current restart message.
+ * @my_tz Current timezone (unused here).
* @file_hdr System activity file standard header.
* @record_hdr Current record header (unused here).
***************************************************************************
*/
__printf_funct_t print_sar_restart(int *tab, int action, char *cur_date, char *cur_time,
- struct file_header *file_hdr,
- struct record_header *record_hdr)
+ char *my_tz, struct file_header *file_hdr,
+ struct record_header *record_hdr)
{
char restart[64];
* @action Action expected from current function (unused here).
* @cur_date Date string of current comment (unused here).
* @cur_time Time string of current comment.
+ * @my_tz Current timezone (unused here).
* @comment Comment to display.
* @file_hdr System activity file standard header (unused here).
* @record_hdr Current record header (unused here).
***************************************************************************
*/
__print_funct_t print_sar_comment(int *tab, int action, char *cur_date, char *cur_time,
- char *comment, struct file_header *file_hdr,
+ char *my_tz, char *comment, struct file_header *file_hdr,
struct record_header *record_hdr)
{
printf("%-11s", cur_time);
/* Display comment */
next = print_special_record(&record_hdr[*curr], flags + S_F_LOCAL_TIME,
&tm_start, &tm_end, R_COMMENT, ifd,
- &rectime, file, 0,
+ &rectime, file, 0, NULL,
file_magic, &file_hdr, act, &sar_fmt,
endian_mismatch, arch_64);
if (next && lines) {
if ((rtype == R_RESTART) || (rtype == R_COMMENT)) {
print_special_record(&record_hdr[0], flags + S_F_LOCAL_TIME,
&tm_start, &tm_end, rtype, ifd,
- &rectime, from_file, 0, &file_magic,
+ &rectime, from_file, 0, NULL, &file_magic,
&file_hdr, act, &sar_fmt, endian_mismatch, arch_64);
}
else {
/* This was a COMMENT record: Print it */
print_special_record(&record_hdr[curr], flags + S_F_LOCAL_TIME,
&tm_start, &tm_end, R_COMMENT, ifd,
- &rectime, from_file, 0,
+ &rectime, from_file, 0, NULL,
&file_magic, &file_hdr, act, &sar_fmt,
endian_mismatch, arch_64);
}
if (!eosaf && (record_hdr[curr].record_type == R_RESTART)) {
print_special_record(&record_hdr[curr], flags + S_F_LOCAL_TIME,
&tm_start, &tm_end, R_RESTART, ifd,
- &rectime, from_file, 0,
+ &rectime, from_file, 0, NULL,
&file_magic, &file_hdr, act, &sar_fmt,
endian_mismatch, arch_64);
}
compute_next_graduation_timestamp(&stamp, xpos);
}
- if (!PRINT_LOCAL_TIME(flags)) {
- printf("<text x=\"-10\" y=\"30\" style=\"fill: #%06x; stroke: none; font-size: 12px; "
- "text-anchor: end\">%s</text>\n",
- svg_colors[palette][SVG_COL_INFO_IDX],
- PRINT_TRUE_TIME(flags) ? svg_p->file_hdr->sa_tzname : "UTC");
- }
+ printf("<text x=\"-10\" y=\"30\" style=\"fill: #%06x; stroke: none; font-size: 12px; "
+ "text-anchor: end\">%s</text>\n",
+ svg_colors[palette][SVG_COL_INFO_IDX],
+ PRINT_LOCAL_TIME(flags) ? svg_p->my_tzname
+ : (PRINT_TRUE_TIME(flags) ? svg_p->file_hdr->sa_tzname
+ : "UTC"));
}
/*