Sponsored Content
Top Forums Shell Programming and Scripting Finding total Percentage CPU usage Post 302417639 by ygemici on Friday 30th of April 2010 07:31:40 AM
Old 04-30-2010
MySQL

Top command output..

Code:
CPU states:  cpu    user    nice  system    irq  softirq  iowait    idle
           total    8.9%    0.0%    4.3%   0.1%     0.8%   19.3%   66.3%
           cpu00    6.6%    0.0%    4.4%   0.5%     2.4%   20.8%   65.0%
           cpu01    4.0%    0.0%    2.3%   0.0%     0.6%   30.4%   62.4%
           cpu02   13.4%    0.0%    0.7%   0.0%     0.0%   16.7%   68.9%
           cpu03    2.1%    0.0%    1.2%   0.0%     0.0%   17.1%   79.2%
           cpu04    6.4%    0.0%    6.1%   0.0%     0.3%   19.3%   67.6%
           cpu05   16.5%    0.0%    4.5%   0.0%     0.0%   32.8%   45.9%
           cpu06    7.1%    0.0%    6.3%   0.0%     0.6%   19.9%   65.9%
           cpu07   12.7%    0.0%   12.0%   0.0%     0.2%   24.7%   50.1%
           cpu08    9.8%    0.0%    9.5%   1.0%     1.1%   13.1%   65.1%
           cpu09    8.8%    0.0%    5.7%   0.5%     6.4%   17.3%   61.0%
           cpu10   16.9%    0.0%    3.0%   0.0%     0.1%    7.1%   72.6%
           cpu11    7.7%    0.0%    3.6%   0.0%     0.2%   15.0%   73.2%
           cpu12    4.4%    0.0%    2.8%   0.0%     0.1%   15.9%   76.6%
           cpu13    9.0%    0.0%    3.0%   0.0%     0.0%   47.5%   40.2%
           cpu14    3.5%    0.0%    0.7%   0.0%     0.3%    0.8%   94.4%
           cpu15   83.5%    0.0%   16.4%   0.0%     0.0%    0.0%    0.0%



And when press the C .. (Collapsed SMP CPU stats)
the output

Code:
CPU states:  cpu    user    nice  system    irq  softirq  iowait    idle
           total   14.2%    0.0%    5.3%   0.1%     0.9%   20.6%   58.7%

Dou you want like this?

Last edited by ygemici; 04-30-2010 at 08:33 AM.. Reason: editing for Redhat 3
 

10 More Discussions You Might Find Interesting

1. HP-UX

How to determine cpu&memory percentage usage per user

Using HP-UX v11 Need to monitor cpu and memory usage, total for system and separately for each user in command-line mode. Found out next ways to monitor total cpu usage under hp-ux: 1) vmstat, also shows free memory 2) sar -M ps -eo user,pcpu - does not work, means 'user-defined format'... (4 Replies)
Discussion started by: hp-ux-user
4 Replies

2. UNIX for Advanced & Expert Users

Finding CPU usage by a Unix Process

Hi, I am designing a load balancer for an application. I am trying to find out the CPU usage by a specifc Unix process (PID is known). I guess I can use ps command to find that. can somebody help me in finding what exact command I should use to find? It is on AIX 5.3. Regards Asutosh (2 Replies)
Discussion started by: asutoshch
2 Replies

3. Shell Programming and Scripting

Help with bash script - Need to get CPU usage as a percentage

I'm writing a bash script to log some selections from a sensors output (core temp, mb temp, etc.) and I would also like to have the current cpu usage as a percentage. I have no idea how to go about getting it in a form that a bash script can use. For example, I would simply look in the output of... (3 Replies)
Discussion started by: graysky
3 Replies

4. UNIX for Dummies Questions & Answers

HOWTO - Total memory and CPU usage ... without top?

Hi all, Is it possible to get total memory usage and free memory usage without top? By Googling I found for total memory usage, use vmstat, for CPU, use mpstat, for disk I/O use iostat, is this correct? Will using sar gives the same result as ALL of these three (3) commands? What about if I... (2 Replies)
Discussion started by: newbie_01
2 Replies

5. UNIX for Dummies Questions & Answers

Total cpu usage in percent(%)

How to determine the total percentage cpu usage of a server having 4 cpu cores(quad core)? (3 Replies)
Discussion started by: proactiveaditya
3 Replies

6. UNIX for Dummies Questions & Answers

Is total CPU usage for sar %user+%system+%iowait?

Hi all Can anyone advise/confirm whether total CPU usage when running sar is %user+%system+%iowait or is it %user+%system only? I want to confirm whether I am having a CPU-bound problem or not. This is a single-CPU VMware machine. $ sar 5 20 Linux 2.6.18-238.5.1.el5... (7 Replies)
Discussion started by: newbie_01
7 Replies

7. Linux

How to calculate total CPU usage from SAR report?

Hi, I want to calculate the total cpu usage from the sar report. Say for example, Linux 2.6.24-21-generic (blade10) 09/10/2012 04:54:36 PM CPU %user %nice %system %iowait %steal %idle 04:54:37 PM all 0.00 0.00 0.00 0.00 ... (1 Reply)
Discussion started by: rohitmd
1 Replies

8. UNIX for Advanced & Expert Users

Finding out total memory usage

Hi, I have a server box with 16GB ram in it, within the server box there are 3 VMs running with a total allocation of 9GB. if I add up all the numbers under memory info using vmstat I get 15.8GB so I can say it adds up to 16Gb... Is there a way to see from the command line how much memory... (2 Replies)
Discussion started by: speedhunt3r
2 Replies

9. Solaris

Total CPU usage on a server

hi, i am using solaris server. I want to find the total CPU usage on a server. Top command will give that result, but here that command is not working. So anyone can help me to find the total CPU usage. (2 Replies)
Discussion started by: Arasu123
2 Replies

10. Solaris

Capture PRSTAT based on CPU usage percentage

Hi, Recently i have write a simple script to capture CPU high usage based on prstat but i found out that it did capture correctly. I need to capture the rows that contains CPU usage more than 3%. Below line which i thought will capture CPU usage based CPU column in prstat(9th parameter) which is... (3 Replies)
Discussion started by: tharmendran
3 Replies
sg_get_cpu_stats(3)					     Library Functions Manual					       sg_get_cpu_stats(3)

NAME
sg_get_cpu_stats, sg_get_cpu_stats_diff, sg_get_cpu_percents - get cpu usage SYNOPSIS
#include <statgrab.h> sg_cpu_percents *sg_get_cpu_percents(void); sg_cpu_stats *sg_get_cpu_stats(void); sg_cpu_stats *sg_get_cpu_stats_diff(void); DESCRIPTION
sg_get_cpu_stats() and sg_get_cpu_stats_diff() both return static pointers of type sg_cpu_stats. sg_get_cpu_stats() returns the total amount of "ticks" the operating system has spent in each of the different states. sg_get_cpu_stats_diff() returns the difference in "ticks" for each of the states since last time sg_get_cpu_stats_diff() or sg_get_cpu_stats() was called. If it has never been called, it will return the result of sg_get_cpu_stats(). The value stored (the "ticks") will vary between operating systems. For example Solaris has a total of 100 per second, while Linux has sub- stantially more. Also, different operating systems store different information - you won't find nice cpu on Solaris for example. Because of this, you will ideally always want to work on a scale against the total, or in percentages. sg_get_cpu_percents() returns a pointer to a static sg_cpu_percents. The function calls sg_get_cpu_stats_diff() and changes the values into percentages. If it has never been called before (and nor has sg_get_cpu_stats() or sg_get_cpu_stats_diff()), the returned percentages will be the systems total ever since its uptime. (Unless the counters have cycled) RETURN VALUES
There are two structures returned by the CPU statistics functions. typedef struct{ long long user; long long kernel; long long idle; long long iowait; long long swap; long long nice; long long total; time_t systime; }sg_cpu_stats; typedef struct{ float user; float kernel; float idle; float iowait; float swap; float nice; time_t time_taken; }sg_cpu_percents; user kernel idle iowait swap nice The different CPU states. systime time_taken The time taken in seconds since the last call of the function, or the system time. SEE ALSO
statgrab(3) WEBSITE
http://www.i-scream.org/libstatgrab/ i-scream $Date: 2005/04/25 11:25:45 $ sg_get_cpu_stats(3)
All times are GMT -4. The time now is 02:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy