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

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat CPU Usage statistics Dump in a text file over a period of time
# 1  
Old 06-28-2017
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.
# 2  
Old 06-28-2017
Hi,

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

Code:
sar -u 1 3600 >> filename

Or
Code:
sar -u 1 3600 -o filename

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

Regards

Gull04
# 3  
Old 06-29-2017
Thanks for the Reply @Gull04.
I am getting information time wise for the following through your given command.

Code:
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.
# 4  
Old 07-04-2017
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.
Code:
>yum install ./epel-release-5.4.noarch.rpm

The output:
Code:
 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.
Code:
[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).
# 5  
Old 07-11-2017
@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.
Code:
-------------------------------------------------
`_Y         "                     i!uLinux                                                            NTMM0DS2                                                         2.6.18-348.el5                                                    nv           u
            <h            “                          š             ֳ            EZ                             s            `_Y    `O     '   _+                   Lx    x     œ                               #        š;m(áw/RJ*  )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                                             rk          &                                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{    RX    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   =z7                   ƒ                                                                             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{    RX    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  qz%                                                                                                 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                                             b6
            
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                                             Fk          &                                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                                                                                                                              
--------------------------------------------------------------------------


Last edited by RudiC; 07-11-2017 at 06:12 PM.. Reason: corrected [/code] tag.
# 6  
Old 09-21-2017
If you know the process, then I assume you know the process ID? If so you can use top.

Code:
top -p PID

If you like colour, you can also use htop.
# 7  
Old 09-21-2017
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.

Code:
sar /var/log/sa/sa13

Will produce a report you can read. Change 13 to another day if you need to.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with speeding up my working script to take less time - how to use more CPU usage for a script

Hello experts, we have input files with 700K lines each (one generated for every hour). and we need to convert them as below and move them to another directory once. Sample INPUT:- # cat test1 1559205600000,8474,NormalizedPortInfo,PctDiscards,0.0,Interface,BG-CTA-AX1.test.com,Vl111... (7 Replies)
Discussion started by: prvnrk
7 Replies

2. Linux

Ps command on cpu usage and time

Hi All, Am very new to Linux and unix ...need below help . need to list of process consuming more than 40% cpu and which are older than 10 days of a particular user .... Thanks V (4 Replies)
Discussion started by: venky456
4 Replies

3. Shell Programming and Scripting

Gathering usage statistics

so i have a script that runs across many servers. i'd like to know how many times this script is being used on each server. the only straight forward, non-intrusive way i can think of doing this is to include a line in the script to make a webcall to a central server. and from that central... (9 Replies)
Discussion started by: SkySmart
9 Replies

4. AIX

Wait time shows high CPU usage

Hi, I can't seem to make sense of this. My wait time is showing really high but vmstat's and topas are showing normal usage. ps aux USER PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND root 9961810 5680.7 0.0 448 384 - A Dec 16 6703072:12 wait ... (2 Replies)
Discussion started by: techy1
2 Replies

5. UNIX for Dummies Questions & Answers

CPU and Memory Statistics Collection Across Many Servers

Hello geeks once again, many thanks for help in times past, you guys are awesome! But am here again, but now this is way heavy for me. Find below for my challenge: *** I need to collect CPU & RAM stats across 26 servers. *** I don't have the luxury of deploying an NMS, if I had it would... (3 Replies)
Discussion started by: infinitydon
3 Replies

6. Shell Programming and Scripting

Searching the lines within a range of time period in a text file

Dear All, Please advice me, I have a text file with one field date and time like below given. I need to find out the lines whchi content the time stamp between Wed May 26 11:03:11 2010 and Wed May 26 11:03:52 2010 both can be included, using awk command which could be an interactive so that I... (6 Replies)
Discussion started by: chinmayadalai
6 Replies

7. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

8. Solaris

Multi CPU Solaris system shows 100% CPU usage.

Hello Friends, On one of my Solaris 10 box, CPU usage shows 100% using "sar", "vmstat". However, it has 4 CPUs and prstat and glance are not showing enough processes to justify high CPU utilization. ========================================================================= $ prstat -a ... (4 Replies)
Discussion started by: mahive
4 Replies

9. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

10. Programming

C/C++ library for CPU statistics

Hi all, This is my first post, so at the beginning I would like to be nice and say: "Hello all!" :) I am looking for a C/C++ library for Linux CPU statistics. All I found is that it is possible to parse two files: /proc/cpuinfo and /proc/stat to gain some needed information, but I would like to... (1 Reply)
Discussion started by: ebucka
1 Replies
Login or Register to Ask a Question