0

I was trying to plot the results of various iostat results. For that I want to use https://clusterbuffer.wordpress.com/file-system-tools/iostat_plot/iostat-plotter-v3/.

Anyhow - for some inexplicable reason, that script has the time format it expects hardcoded and its expecting a 12hr AM/PM time format which I dont think is part of ANY linux locale setting. Im looking for a way to tell iostat -t to output in an AM/PM format and am failing at that. Supposedly its using the env var S_TIME_FORMAT which is unknown to me and seems to be iostat specific AND undocumented. The systems/user LC_TIME is set to 'C' as per usual. Any idea how to coax iostat into using the am/pm format? Since iostat is a binary I cannot modify the way it calls strftime/localtime. Thanks in advance!

# locale
LANG=en_US.UTF-8
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=C 
Heinz39
  • 3
  • 2

3 Answers3

0

The locale you are looking for is en_US:

[xxx]# export LANG=C
[xxx]# iostat -t
Linux 4.14.8-300.fc27.x86_64 (osvetlik.unicorn)     01/10/18    _x86_64_    (4 CPU)

01/10/18 18:36:47
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          26.26    0.09    5.56    0.09    0.00   68.00

[xxx]# export LANG="en_US.UTF-8"
[xxx]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
[xxx]# iostat -t
Linux 4.14.8-300.fc27.x86_64 (osvetlik.unicorn)     01/10/2018  _x86_64_    (4 CPU)

01/10/2018 06:37:41 PM
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          26.25    0.09    5.56    0.09    0.00   68.01

The important locale variable here is LC_TIME (but you have to change LC_ALL in case you have it set as it prevents different setting of other LC_ variables). You have to set this variable to en_US to have the time in the correct format. Having only LANG set to en_US doesn't help. Just use locale command to verify that LC_TIME is set correctly.

Output without LC_ALL set:

[xxx]# export LC_ALL= 
[xxx]# export LC_TIME="en_US.UTF-8"
[xxx]# locale
LANG=C
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME=en_US.UTF-8
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=
[xxx]# iostat -t
Linux 4.14.8-300.fc27.x86_64 (osvetlik.unicorn)     01/12/2018  _x86_64_    (4 CPU)

01/12/2018 09:48:05 AM

And with LC_ALL:

[xxx]# export LC_ALL="en_US.UTF-8"
[xxx]# locale
LANG=C
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
[xxx]# iostat -t
Linux 4.14.8-300.fc27.x86_64 (osvetlik.unicorn)     01/12/2018  _x86_64_    (4 CPU)

01/12/2018 09:49:38 AM

Short solution:

LC_ALL="en_US.UTF-8" iostat -t
0

cant use formating in comments, so pasting code block here:

the system already has that locale defined in /etc/locale.conf even. Thats not it unfortunately:

[root@xxx]# echo $LANG
en_US.UTF-8
[root@xxx]# iostat -t
Linux 3.10.0-514.6.1.el7.x86_64 (xxx)  01/11/18        _x86_64_            (48 CPU)

01/11/18 08:43:46
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
[...]
Heinz39
  • 3
  • 2
0

With the help of Ondřej I figured it out.

LC_ALL=en_US.UTF-8 iostat -t    

works.

Heinz39
  • 3
  • 2