|
|
f76ab7 |
From f3964e0fa19e0c33470f37014ebcebf0b4253363 Mon Sep 17 00:00:00 2001
|
|
|
f76ab7 |
From: Michal Sekletar <msekleta@redhat.com>
|
|
|
f76ab7 |
Date: Fri, 30 Sep 2016 18:05:44 +0200
|
|
|
f76ab7 |
Subject: [PATCH] sar: make buffers that hold timestamps bigger
|
|
|
f76ab7 |
MIME-Version: 1.0
|
|
|
f76ab7 |
Content-Type: text/plain; charset=UTF-8
|
|
|
f76ab7 |
Content-Transfer-Encoding: 8bit
|
|
|
f76ab7 |
|
|
|
f76ab7 |
On systems that use Korean UTF-8 locale sar will not print timestamp
|
|
|
f76ab7 |
because there is not enough space in the buffer.
|
|
|
f76ab7 |
|
|
|
f76ab7 |
I bumped buffer size to 64 bytes because I figured out that 32 bytes is
|
|
|
f76ab7 |
still not enough to print out timestamp when using some glibc supported
|
|
|
f76ab7 |
locales.
|
|
|
f76ab7 |
|
|
|
f76ab7 |
$ LC_TIME=ko_KR.UTF-8 ./sar 1 1
|
|
|
f76ab7 |
|
|
|
f76ab7 |
Before:
|
|
|
f76ab7 |
Linux 4.7.2-201.fc24.x86_64 (morgoth.usersys.redhat.com) 2016년 09월 30일 _x86_64_ (4 CPU)
|
|
|
f76ab7 |
|
|
|
f76ab7 |
CPU %user %nice %system %iowait %steal %idle
|
|
|
f76ab7 |
all 4.51 0.00 2.51 0.00 0.00 92.98
|
|
|
f76ab7 |
Average: all 4.51 0.00 2.51 0.00 0.00 92.98
|
|
|
f76ab7 |
|
|
|
f76ab7 |
After:
|
|
|
f76ab7 |
Linux 4.7.2-201.fc24.x86_64 (morgoth.usersys.redhat.com) 2016년 09월 30일 _x86_64_ (4 CPU)
|
|
|
f76ab7 |
|
|
|
f76ab7 |
18시 18분 36초 CPU %user %nice %system %iowait %steal %idle
|
|
|
f76ab7 |
18시 18분 37초 all 3.76 0.00 2.26 0.00 0.00 93.98
|
|
|
f76ab7 |
Average: all 3.76 0.00 2.26 0.00 0.00 93.98
|
|
|
f76ab7 |
---
|
|
|
f76ab7 |
sa.h | 2 +-
|
|
|
f76ab7 |
sar.c | 4 ++--
|
|
|
f76ab7 |
2 files changed, 3 insertions(+), 3 deletions(-)
|
|
|
f76ab7 |
|
|
|
f76ab7 |
diff --git a/sa.h b/sa.h
|
|
|
f76ab7 |
index 54e7a4e..c11dbe9 100644
|
|
|
f76ab7 |
--- a/sa.h
|
|
|
f76ab7 |
+++ b/sa.h
|
|
|
f76ab7 |
@@ -199,7 +199,7 @@
|
|
|
f76ab7 |
#define NR_USB_PREALLOC 5
|
|
|
f76ab7 |
|
|
|
f76ab7 |
#define UTSNAME_LEN 65
|
|
|
f76ab7 |
-#define TIMESTAMP_LEN 16
|
|
|
f76ab7 |
+#define TIMESTAMP_LEN 64
|
|
|
f76ab7 |
#define HEADER_LINE_LEN 512
|
|
|
f76ab7 |
|
|
|
f76ab7 |
/* Maximum number of args that can be passed to sadc */
|
|
|
f76ab7 |
diff --git a/sar.c b/sar.c
|
|
|
f76ab7 |
index e8ad83e..8dd998b 100644
|
|
|
f76ab7 |
--- a/sar.c
|
|
|
f76ab7 |
+++ b/sar.c
|
|
|
f76ab7 |
@@ -469,10 +469,10 @@ int write_stats(int curr, int read_from_file, long *cnt, int use_tm_start,
|
|
|
f76ab7 |
}
|
|
|
f76ab7 |
|
|
|
f76ab7 |
/* Set previous timestamp */
|
|
|
f76ab7 |
- if (set_record_timestamp_string(!curr, timestamp[!curr], 16))
|
|
|
f76ab7 |
+ if (set_record_timestamp_string(!curr, timestamp[!curr], TIMESTAMP_LEN))
|
|
|
f76ab7 |
return 0;
|
|
|
f76ab7 |
/* Set current timestamp */
|
|
|
f76ab7 |
- if (set_record_timestamp_string(curr, timestamp[curr], 16))
|
|
|
f76ab7 |
+ if (set_record_timestamp_string(curr, timestamp[curr], TIMESTAMP_LEN))
|
|
|
f76ab7 |
return 0;
|
|
|
f76ab7 |
|
|
|
f76ab7 |
/* Check if we are beginning a new day */
|
|
|
f76ab7 |
--
|
|
|
f76ab7 |
2.9.3
|
|
|
f76ab7 |
|