Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sar command time display format 1

Status
Not open for further replies.

nychris

MIS
Dec 4, 2004
103
US
I have a few systems that are the same operating system (RHEL 5.6) and all have the same version of sar installed (sysstat-7.0.2-3.el5_5.1). On some systems, the time is shown in 12-hour format.

Code:
serverA# sar -r | head -4

12:00:01 AM kbmemfree kbmemused  %memused kbbuffers  kbcached kbswpfree kbswpused  %swpused  kbswpcad
12:10:01 AM    225116  65763136     99.66    620496  37077276   8385680       240      0.00         0
12:20:01 AM     78044  65910208     99.88    589044  37734804   8385680       240      0.00         0
12:30:01 AM    768460  65219792     98.84    538552  37651404   8385680       240      0.00         0

On others, it's shown in 24-hour format.

Code:
serverB# sar -r | head -4

00:00:01    kbmemfree kbmemused  %memused kbbuffers  kbcached kbswpfree kbswpused  %swpused  kbswpcad
00:10:01        79612  65767076     99.88     22732  60181544   8385696       224      0.00         0
00:20:01       101196  65745492     99.85    130632  59343868   8385692       228      0.00         0
00:30:01       110268  65736420     99.83    223936  59000392   8385692       228      0.00         0

If I SSH to serverA (who was displaying it in 12-hour format), it shows it in 24-hour now.

Code:
serverC# ssh serverA sar -r

00:00:01    kbmemfree kbmemused  %memused kbbuffers  kbcached kbswpfree kbswpused  %swpused  kbswpcad
00:10:01       193596  73852752     99.74    266448  58820468  16383688       304      0.00         0
00:20:01      1254992  72791356     98.31    272432  58777088  16383688       304      0.00         0
00:30:01      1585748  72460600     97.86    277396  58407776  16383688       304      0.00         0

What is it reading that determines if it uses 12-hour or 24-hour format? I want to force it to one or the other for scripting reasons. All servers are the same timezones.
 
I assume it is the default system locale. What is the output of the locale command on each system?

You can override it with your preferred value to produce the desired results:

Code:
root@ganymede:/etc # sar 5 1
Linux 2.6.18-128.el5 (ganymede)        10/31/2011

09:11:27 AM       CPU     %user     %nice   %system   %iowait    %steal     %idle
09:11:32 AM       all      0.00      0.00      0.00      0.00      0.00    100.00
Average:          all      0.00      0.00      0.00      0.00      0.00    100.00
root@ganymede:/etc # LC_ALL=en_US.utf8 sar 5 1
Linux 2.6.18-128.el5 (ganymede)        10/31/2011

09:11:41 AM       CPU     %user     %nice   %system   %iowait    %steal     %idle
09:11:46 AM       all      0.00      0.00      0.00      0.05      0.00     99.95
Average:          all      0.00      0.00      0.00      0.05      0.00     99.95
root@ganymede:/etc # LC_ALL=en_AU.utf8 sar 5 1
Linux 2.6.18-128.el5 (ganymede)        31/10/11

09:11:50          CPU     %user     %nice   %system   %iowait    %steal     %idle
09:11:55          all      0.05      0.00      0.00      0.20      0.00     99.75
Average:          all      0.05      0.00      0.00      0.20      0.00     99.75
root@ganymede:/etc #

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Incidentally, the system setting for this value is stored in /etc/sysconfig/i18n.

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
I just checked and all of the servers have the same values in /etc/sysconfig/i18n, yet some display a 12-hour format while others a 24-hour format.

--
Chris
RHCE, SCSA, AIX5L, LPIC, CNE, CCNA, MCSE
 
How about when you type locale at the prompt before running the sar command, what do you get?

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
You are right! Looking at the locale output I was able to determine that setting this variable will force sar to display it's output in 24-hour times.

export LC_TIME="POSIX"


Thanks Annihilannic! I remember you from 8 years ago back when I was very active on the board under the now retired name fluid11.

--
Chris
RHCE, SCSA, AIX5L, LPIC, CNE, CCNA, MCSE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top