CPU Usage statistics Dump in a text file over a period of time

I am facing issue related to performance of one customized application running on RHEL 5.9. The application stalls for some unknown reason that I need to track. For that I require some tool or shell scripts that can monitor the CPU usage statistics (what we get in TOP or in more detail by other means) with timestamp (may be 1 second periodically) into a plain .txt(ASCII file) file.I require to dump the statistics over a period of 1 hour. Can anybody help me out in this regard?
The above is my idea.But if some one is having other means to capture the process statistics over period of one hour, please share the same too.

Hi,

It should be possible to collect the information the you require with the "sar" command as follows;

sar -u 1 3600 >> filename

Or

sar -u 1 3600 -o filename

You will have to look to the CPU load, as running sar will impose a load.

Regards

Gull04

Thanks for the Reply @Gull04.
I am getting information time wise for the following through your given command.

Time      CPU      %user   %nice  %system  %iowait   %steal    %ideal 

But the thing is that I have identified the application which is not responding
for a particular span of time period. I want to get the statistics of the Application during that span of time. By your given command I can see the CPU information overall.
But I need to have individual statistics of each application running at that time
period so that I can detect if any other application is causing the hang of my application or not? I have almost 10 customized application running on the system which are talking among themselves too.
Can you suggest something.

I have searched for one tool name "Atop" that can monitor activities over a period of time. But is requires epel-release-5-4.noarch.rpm as prerequisite what I understand from its installation procedure.
The steps I followed is as follows.
1) Install epel-release-5-4.noarch.rpm.But it trouws error.

>yum install ./epel-release-5.4.noarch.rpm

The output:

 Could not retrieve mirrorlist http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=x86_64 error was [Error 4] I0Error: <urlopen error (-3, 'Temporary failure in name resolution')>
Error: Cannot retrieve repository metadata (repmod.xml) for repository: epel.Please verify its path and check again 

---------------

I have checked /ete/yum.repos.d/epel.repo file and fould the following lines.

[epel]
name=Extra Packages for Enterprise Linux 5 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 5 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch/debug
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 5 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/5/SRPMS
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-5&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
gpgcheck=1
 

Can somebody help me out to troubleshoot the same.
I am having RHEL 5.9 installed in X64 machine and I have used epel-release-5.4.noarch.rpm(what I download fro some site in the Internet).

@gull04: I have tried to dump the information through SAR in a text file.But the dumped file is not readable.Can you please tell how to dump it in readable ASCII format.

-------------------------------------------------
�`_Y    ��     "                     i!�uLinux                                                            NTMM0DS2                                                         2.6.18-348.el5                                                    nv           u��
            <�h�            �            ��              ���             �ֳ�            EZ�                             s��            �`_Y    `O     '��   �_+�                   Lx    x     ��    �    ���    ���                   ���#   �     �;m(�á�w�/��R�J*�  )n                         �  �                 J   =   4   5                                                                      3#            �
            �
             1�
             �              ~�                                             ��
            ��             Uy             3              i�                                             T�
            ;G             $             �              �                                             Gf�
            ��              ��                               ��                                             ��
            p�              <�                 (              ��                                             �%�
            g�              �F
             �              B�                                             O�
            x�             �,             H              ��                                                 �V
            �,             e�0             �              \y                                             ��6
            
0;             D6?             T              ��                                             �^�
            ��                 G             F              "`                                             ��
            ��             w             f              �                                             ��
            k             0�             :              �E                                             m�
            2�              �
             �              W�                                             �
            �I             �             �7              �                                             �
                         i*             1                                                           iW�
            J�              1�             
                  ��                                             �N�
            ��              �f                           �Y                                             {#�
            ">             i�             �
              E�                                             6c9
            ^Q             �}             ,              �E                                             �[)
            �
             %Z�             �              �                                             �zc
            �             ��J             �              L�                                             uhn
            ֓             EA=             5              �                                             �L
            |�             ��U             u              ˶                                             ��                �B             ��             �              wI                                             r�k          &                                4     [   B  c   �   k   �   s   �   {   |  �   �  �   a   �      �       �      �       �      �      �      �      �   i   �      �   @   �      �   1   �   �*  �      �       ����    ����    ����    ����                "0                              �M      �?     
      �?     k�     �>     ��           ��     �      �                                                            ��             1      *�     �"     G                                                     �+                              V      ?�                  ��     ��     I�     �      �     f     �x                                                             �h                       2�      V $     -"                                                      %                              Xl      �      y
      ,�     �     �H     ��      7      �     �F     ��                                                             {              d      k�      �W     9                                                      �                              �      c/            _Q         P*      �~     �             B�     A+     �9                                                             �,              D       N      36     *                                                      =                                      �P             �     ��      )s      �3              �     Ȩ     �                                                              �*                     v          �      -/                                                      `                                         �^     ,;5     qID     sK     лn     ?     �     �*      ��                                                             cJo                    �      ��*    w�                                                     r�
                             <�/     ��     a     /-�     ��7     �5C     ��     �k!     9�      �      ǡ                                                             ��a                     /      �P�                                                                �                             cG0     uӼ     �         h�     /�     .+     �=�    j
     z�      �      ��                                                             ޿-                     �       �u�                                                            s
                             ^       Er�     &B     ��     T     ��!     �~�    ��     o�      �      (�                                                             �.                     �       ��I                                                           �z                                    �i=     �      �     1�#     ��2     6�     &/N     *�      �      �                                                             '�h                     �       ��    �                                                      ��                                    ��#     �_          (+     �     ՚#     +�(     m4           �      ��
                                                             �F                     �       �w*    G9                                                                                                                                                                                                                                                                                                                                                                     �
      �     �*      9�      oh     Hy      \     �|          ��      0�                                                             �g              ^      $B     E�      �                                                                                      e      �X     n.     ��      �      CN      �O     $b     e     VO                                                                   5              0+      �      �      �                                                                                      8      ��      i�     ��      @     \�      ��     x     �w     ��     y"                                                             /�             x                    �3                                                                                      �y      'I     '�     0     3m<     [     ��      j6     �A     e�     �                                                             im             �F      �      *      L                                                                                      �#     �b     '�
     �u�     8��     ��r     T     %     �     �_      ��                                                             MS             %V     �B              �
                                                                                      �*p    �G�     ��K     ��      �$     �)&     �    �x    �q            ϑ                                                             BGj             �ə     :       �|
    Y\@                                                                                     |    腕     ��     �     :�     }�     On�     �\�    �@      �      �<                                                             ;�?             *V             �     ��                                                                                     �     ���    ��    �     �     q     �T�     2i�     W�      "      ��                                                             �i4             sA           *Ɨ    nb�                                                                                     �5     ?%    ��    �     �7     �     <�z    5f�     (F      �      �(                                                             �#             ��            �Y}     �                                                                                     R{    R�X    �z@    �2     v      _-    ��C    �be     $Z      7      *B                                                             �`             ��           ��
    �                                                                                      �y7    6p     '��        �    <�    Q�    �xz     wP     <�      W+      �                                                             ��a             �ͩ    [�     �8I    �3                                     lj    lj    0�]i   0�]i                                                                                                   lo              !
N    �G�    ����'  љ�j                   ��                                                                             eth0            K0�    �iD    �NQ�   =z��7                   ���                                                                             eth1                                                                                                                                            eth2            ��D    ^Ma:        �@5o  ww*z%                                                                                                 eth3                                                                                                                                            sit0            VQ�\    p�,    �;Mm<  YYH                   ��                                                                            bond0                                                                                                                                           ?                                                                                                                                               ?               �&v           ���
            ��h�            8�            ��              ��             �߳�            IZ�                             ���            �`_Y    tO     <'��   Q*+�                     x    x     (�    �    ���    ���                   m�#   �     �Qm(�á�����Rt��  8n                         �  *             J   =   4   6                                                                      3$            l�
            �
             7�
             �              ~�                                             ��
            ��             Uy             3              i�                                             ��
            ;G             $             �              �                                             �f�
            ��              ��                               ��                                             ��
            q�              =�                 (              ��                                             �%�
            g�              �F
             �              B�                                             ��
            z�             ,             H              �                                                 ?V
            �,             e�0             �              \y                                             ��6
            
0;             D6?             T              ��                                             Y_�
            ��                 G             F              "`                                             ��
            ��             w             f              �                                             ��
            k             0�             :              �E                                             vm�
            2�              �
             �              W�                                             ��
            �I             �             �7              !�                                             r�
                         k*             1                                                           �W�
            J�              3�             
                  ��                                             �N�
            ��              �f                           �Y                                             �#�
            ">             j�             �
              E�                                             �c9
            ^Q             �}             ,              �E                                             �[)
            
             RZ�             �              �                                             A{c
            �             ��J             �              L�                                             �hn
            ֓             IA=             5              �                                             �L
            |�             ��U             u              ̶                                             숱                �B             ��             �              I                                             \�k          &                                4     [   B  c   �   k   �   s   �   {   |  �   �  �   a   �      �       �      �       �      �      �      �      �   i   �      �   @   �      �   1   �   �*  �      �       ����    ����    ����    ����                "0                              �M      �?     
      �?     k�     �>     ��           ��     �      �                                                            ��             1      *�     �"     G                                                     �+                              V      ?�                  ��     ��     I�     �      �     f     �x                                                             �h                       2�      V $     -"                                                      %                              Xl      �      y
      ,�     �     �H     ��      7      �     �F     ��                                                             {              d      k�      �W     9                                                      �                              �      c/            _Q         P*      �~     �             B�     A+     �9                                                             �,              D       N      36     *                                                      =                                      �P             �     ��      )s      �3              �     Ȩ     �                                                              �*                     v          �      -/                                                      `                                         �^     ,;5     qID     K     лn     ?     �     �*      ��                                                             cJo                    �      ��*    w�                                                     r�
                             <�/     ��     a     /-�     ��7     �5C     ��     �k!     9�      �      ǡ                                                             ��a                     /      �P�                                                                �                             cG0     *Ӽ     �         h�     /�     .+     �=�    j
     z�      �      ��                                                             ޿-                     �       �u�                                                            s
                             ^       Er�     &B     ��     T     ��!     �~�    ��     o�      �      (�                                                             �.                     �       ��I                                                           �z                                    �i=     �      �     1�#     ��2     6�     &/N     *�      �      �                                                             '�h                     �       ��    �                                                      ��                                    ��#     �_          (+     �     ՚#     +�(     m4           �      ��
                                                             �F                     �       �w*    G9                                                                                                                                                                                                                                                                                                                                                                     �
      �     �*      9�      oh     Hy      \     �|          ��      0�                                                             �g              ^      $B     E�      �                                                                                      e      �X     n.     ��      �      CN      �O     $b     e     VO                                                                   5              0+      �      �      �                                                                                      8      ��      i�     ��      @     \�      ��     x     �w     ��     y"                                                             /�             x                    �3                                                                                      �y      'I     '�     0     3m<     [     ��      j6     �A     e�     �                                                             im             �F      �      *      L                                                                                      �#     �b     '�
     �u�     C��     ��r     T     %     �     �_      ��                                                             MS             %V     �B              �
                                                                                      �*p    �G�     ��K     ��      �$     �)&     �    &y    �q            ϑ                                                             BGj             �ə     :       �|
    Y\@                                                                                     |    腕     ��     �     :�     }�     On�     �\�    �@      �      �<                                                             ;�?             *V             �     ��                                                                                     �     ���    ��    �     �     q     �T�     2i�     W�      "      ��                                                             �i4             sA           *Ɨ    nb�                                                                                     �5     ?%    ��    �     �7     �     �z    5f�     (F      �      �(                                                             �#             ��            �Y}     �                                                                                     R{    R�X    �z@    �2     v      _-    ��C    �be     $Z      7      *B                                                             �`             ��           ��
    �                                                                                      �y7    6p     ��        �    <�    Q�    �xz     wP     <�      W+      �                                                             ��a             �ͩ    [�     �8I    �3                                     �j    �j    i�`i   i�`i                                                                                                   lo              �)
N    H�    �
�'  _όj                   
��                                                                             eth0            �0�    *lD    VlQ�   &��7                   ���                                                                             eth1                                                                                                                                            eth2            ���D    Xa:    ZA5o  q�z%                                                                                                 eth3                                                                                                                                            sit0            HZ�\    8�,    �yom<  ��YYH                   ��                                                                            bond0                                                                                                                                           ?                                                                                                                                               ?               50v           >��
            ��h�            :�            ��              ��             ���            IZ�                             ���            �`_Y    tO     <'��   ��+�                   ��w    x     (�    �    ���    ���                    $q�#   �     �Um(�á=�����R�®�  7n                         �  �             J   =   4   6                                                                      3%            ѷ
            �
             7�
             �              ~�                                             q��
            ��             Uy             3              i�                                             ��
            ;G             $             �              �                                             g�
            ��              ��                               ��                                             z��
            q�              =�                 (              ��                                             ]&�
            g�              �F
             �              B�                                             
�
            z�             ,             H              ��                                                 �V
            �,             f�0             �              \y                                             b�6
            
0;             D6?             T              ��                                             �_�
            ��                 G             F              "`                                             }��
            ��             w             f              �                                             X�
            k             1�             :              �E                                             �m�
            2�              �
             �              W�                                             Q�
            �I             �             �7              !�                                             ֶ
                         k*             1                                                           .X�
            J�              3�             
                  ��                                             \O�
            ��              �f                           �Y                                             C$�
            ">             j�             �
              E�                                             �c9
            ^Q             �}             ,              �E                                             +\)
            
             SZ�             �              �                                             �{c
            �             ��J             �              L�                                             8in
            ֓             IA=             5              �                                             �L
            |�             ��U             u              Ͷ                                             M��                �B             ��             �              �I                                             F�k          &                                4     [   B  c   �   k   �   s   �   {   |  �   �  �   a   �      �       �      �       �      �      �      �      �   i   �      �   @   �      �   1   �   �*  �      �       ����    ����    ����    ����                "0                              �M      �?     
      �?     k�     �>     ��           ��     �      �                                                            ��             1      *�     �"     G                                                     �+                              V      ?�                  ��     ��     I�     �      �     f     �x                                                             �h                       2�      V $     -"                                                      %                              Xl      �      y
      ,�     �     �H     ��      7      �     �F     ��                                                             {              d      k�      �W     9                                                      �                              �      c/            _Q         P*      �~     �             B�     A+     �9                                                             �,              D       N      36     *                                                      =                                      �P             �     ��      )s      �3              �     Ȩ     �                                                              �*                     v          �      -/                                                      `                                         �^     ,;5     qID     �K     лn     ?     �     �*      ��                                                             cJo                    �      �*    w�                                                     r�
                             <�/     ��     a     /-�     ��7     �5C     ��     �k!     9�      �      ǡ                                                             ��a                     /      �P�                                                                �                             cG0     �Ӽ     �         h�     /�     .+     �=�    j
     z�      �      ��                                                             ޿-                     �       �u�                                                            s
                             ^       Er�     &B     ��     T     ��!     �~�    ��     o�      �      (�                                                             �.                     �       ��I                                                           �z                                    �i=     �      �     1�#     ��2     6�     &/N     *�      �      �                                                             _�h                     �       ��    �                                                      ��                                    ��#     �_          (+     �     ՚#     +�(     m4           �      ��
                                                             �F                     �       �w*    G9                                                                                                                              
--------------------------------------------------------------------------

If you know the process, then I assume you know the process ID? If so you can use top.

top -p PID

If you like colour, you can also use htop.

the /var/log/sa/sadd where dd is the day of the month.
It is NOT created by the sar command - it comes from the sa1 command which in turn is usually called by the sadc command.

sar /var/log/sa/sa13

Will produce a report you can read. Change 13 to another day if you need to.