]> granicus.if.org Git - sysstat/commitdiff
sar/sadf: Add timezone value in binary data file
authorSebastien GODARD <sysstat@users.noreply.github.com>
Tue, 1 Oct 2019 14:57:49 +0000 (16:57 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Tue, 1 Oct 2019 14:57:49 +0000 (16:57 +0200)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
sa.h
sadc.c

diff --git a/sa.h b/sa.h
index df46db10a328ab137ba377cb4f5c20505a945cf1..3c3a0c7e10334bc8e83f364c5517833f9d7146a6 100644 (file)
--- a/sa.h
+++ b/sa.h
 #define DEF_TMEND      "18:00:00"
 
 #define UTSNAME_LEN    65
+#define TZNAME_LEN     8
 #define HEADER_LINE_LEN        512
 
 /*
@@ -584,6 +585,10 @@ struct file_header {
         * Machine architecture.
         */
        char sa_machine[UTSNAME_LEN];
+       /*
+        * Timezone value.
+        */
+       char sa_tzname[TZNAME_LEN];
 };
 
 #define FILE_HEADER_SIZE       (sizeof(struct file_header))
diff --git a/sadc.c b/sadc.c
index 022af0049dba3417ded54d6c3a4a0c51419827b9..22e259c04494951211acfd8c6c5e5a44050f1c68 100644 (file)
--- a/sadc.c
+++ b/sadc.c
@@ -59,6 +59,8 @@ char *sccsid(void) { return (SCCSID); }
 extern time_t __unix_time;
 #endif
 
+extern char *tzname[2];
+
 long interval = 0;
 uint64_t flags = 0;
 
@@ -518,6 +520,11 @@ void setup_file_hdr(int fd)
        strncpy(file_hdr.sa_machine, header.machine, UTSNAME_LEN);
        file_hdr.sa_machine[UTSNAME_LEN - 1]  = '\0';
 
+       /* Get timezone value and save it */
+       tzset();
+       strncpy(file_hdr.sa_tzname, tzname[0], TZNAME_LEN);
+       file_hdr.sa_tzname[TZNAME_LEN - 1] = '\0';
+
        /* Write file header */
        if (write_all(fd, &file_hdr, FILE_HEADER_SIZE) != FILE_HEADER_SIZE) {
                p_write_error();