From: Sebastien GODARD Date: Mon, 13 Jan 2014 21:07:02 +0000 (+0100) Subject: sadf now displays file creation time X-Git-Tag: v10.2.1~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aea45615db16919ce901e2f5239985bf0c5cb36f;p=sysstat sadf now displays file creation time sadf -H, sadf -x and sadf -j now display the creation time of the datafile. This time was available in the header of the datafile. Time is displayed in UTC. Signed-off-by: Sebastien GODARD --- diff --git a/sadf_misc.c b/sadf_misc.c index 4220f09..2cfd263 100644 --- a/sadf_misc.c +++ b/sadf_misc.c @@ -480,7 +480,7 @@ __printf_funct_t print_xml_header(int *tab, int action, char *dfile, struct file_header *file_hdr, __nr_t cpu_nr, struct activity *act[], unsigned int id_seq[]) { - struct tm rectime; + struct tm rectime, *loc_t; char cur_time[32]; if (action & F_BEGIN) { @@ -507,6 +507,12 @@ __printf_funct_t print_xml_header(int *tab, int action, char *dfile, get_file_timestamp_struct(flags, &rectime, file_hdr); strftime(cur_time, 32, "%Y-%m-%d", &rectime); xprintf(*tab, "%s", cur_time); + + if ((loc_t = gmtime((const time_t *) &file_hdr->sa_ust_time)) != NULL) { + strftime(cur_time, sizeof(cur_time), "%T", loc_t); + xprintf(*tab, "%s", cur_time); + } + } if (action & F_END) { xprintf(--(*tab), ""); @@ -537,7 +543,7 @@ __printf_funct_t print_json_header(int *tab, int action, char *dfile, struct file_header *file_hdr, __nr_t cpu_nr, struct activity *act[], unsigned int id_seq[]) { - struct tm rectime; + struct tm rectime, *loc_t; char cur_time[32]; if (action & F_BEGIN) { @@ -560,6 +566,13 @@ __printf_funct_t print_json_header(int *tab, int action, char *dfile, get_file_timestamp_struct(flags, &rectime, file_hdr); strftime(cur_time, 32, "%Y-%m-%d", &rectime); xprintf0(*tab, "\"file-date\": \"%s\"", cur_time); + + if ((loc_t = gmtime((const time_t *) &file_hdr->sa_ust_time)) != NULL) { + strftime(cur_time, sizeof(cur_time), "%T", loc_t); + printf("\n"); + xprintf0(*tab, "\"file-utc-time\": \"%s\"", cur_time); + } + } if (action & F_END) { printf("\n"); @@ -590,6 +603,8 @@ __printf_funct_t print_hdr_header(int *tab, int action, char *dfile, struct activity *act[], unsigned int id_seq[]) { int i, p; + struct tm *loc_t; + char cur_time[32]; /* Actions F_BEGIN and F_END ignored */ if (action & F_BEGIN) { @@ -607,6 +622,12 @@ __printf_funct_t print_hdr_header(int *tab, int action, char *dfile, file_hdr->sa_sysname, file_hdr->sa_release, file_hdr->sa_nodename, file_hdr->sa_machine, cpu_nr > 1 ? cpu_nr - 1 : 1); + + if ((loc_t = gmtime((const time_t *) &file_hdr->sa_ust_time)) != NULL) { + printf(_("File time: ")); + strftime(cur_time, sizeof(cur_time), "%T", loc_t); + printf("%s UTC\n", cur_time); + } printf(_("Size of a long int: %d\n"), file_hdr->sa_sizeof_long);