]> granicus.if.org Git - sysstat/commitdiff
sadf now displays file creation time
authorSebastien GODARD <sysstat@orange.fr.fake>
Mon, 13 Jan 2014 21:07:02 +0000 (22:07 +0100)
committerSebastien GODARD <sysstat@orange.fr.fake>
Mon, 13 Jan 2014 21:14:23 +0000 (22:14 +0100)
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 <sysstat@orange.fr.fake>
sadf_misc.c

index 4220f09b8f312fdb47c482fc10fe80eb269f3191..2cfd263441ff3569169948f2d3c36e357c64fb16 100644 (file)
@@ -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, "<file-date>%s</file-date>", 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, "<file-utc-time>%s</file-utc-time>", cur_time);
+               }
+
        }
        if (action & F_END) {
                xprintf(--(*tab), "</host>");
@@ -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);