Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

nychris (MIS)
28 Oct 11 19:22
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.
Helpful Member!  Annihilannic (MIS)
30 Oct 11 18:14
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
tgmlify - code syntax highlighting for your tek-tips posts

Annihilannic (MIS)
30 Oct 11 18:16
Incidentally, the system setting for this value is stored in /etc/sysconfig/i18n.

Annihilannic
tgmlify - code syntax highlighting for your tek-tips posts

nychris (MIS)
31 Oct 11 2:04
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

Annihilannic (MIS)
31 Oct 11 19:38
How about when you type locale at the prompt before running the sar command, what do you get?

Annihilannic
tgmlify - code syntax highlighting for your tek-tips posts

nychris (MIS)
1 Nov 11 15:40
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

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close