Command to find total CPU utilization?

  • Follow


Hello,
    I am trying to find a command that will provide the total CPU
utilization for the system.   I am starting an application that has
many processes and it's started by multiple schemas.  This same
application has mutex problems and hold CPU's until each component
starts successfully.   So I inserted a piece of code that executes
"prstat -t -u username 1 1" and greps and awks the percentage our of
the result, then if that is greater than 70% it sleeps.  Once the
percentage drops below 70% it will continue with startup.  Just a
simple way of throtling startup.
   Prstat will provide information for each user, or process, but not
total.   vmstat and mpstat pretty much the same.   The only thing I can
think of is to use the output of the prstat and add the cpu totals
together to come up with the complete total, but something tells me
there must be a simpler way.   Any help is appreciated.  Thanks.

PERCENT=`prstat -u $APP_USER -t 1 1 | grep $APP_USER| awk '{print $7}'
| sed s/%//g`
                wait_count="0"
                until [[ $PERCENT -le 70 ]]; do
                        echo "Process over 40 $APP_USER"
                        sleep 30
                        PERCENT=`prstat -u $APP_USER -t 1 1 | grep
egatess | awk '{print $7}' | sed s/%//g`
                        wait_count=$wait_count+1
                        if [ $wait_count -ge 60 ]; then
                                #message to pager
                                #message to log
                                #exit 1
                        fi

                        # Sleep until processes stabilize
                done

0
Reply snoopy_ (19) 10/27/2006 5:26:02 PM

snoopy_@excite.com wrote:
> Hello,
>     I am trying to find a command that will provide the total CPU
> utilization for the system.   I am starting an application that has
> many processes and it's started by multiple schemas.  This same
> application has mutex problems and hold CPU's until each component
> starts successfully.   So I inserted a piece of code that executes
> "prstat -t -u username 1 1" and greps and awks the percentage our of
> the result, then if that is greater than 70% it sleeps.  Once the
> percentage drops below 70% it will continue with startup.  Just a
> simple way of throtling startup.
>    Prstat will provide information for each user, or process, but not
> total.   vmstat and mpstat pretty much the same.   The only thing I can
> think of is to use the output of the prstat and add the cpu totals
> together to come up with the complete total, but something tells me
> there must be a simpler way.   Any help is appreciated.  Thanks.
> 
> PERCENT=`prstat -u $APP_USER -t 1 1 | grep $APP_USER| awk '{print $7}'
> | sed s/%//g`
>                 wait_count="0"
>                 until [[ $PERCENT -le 70 ]]; do
>                         echo "Process over 40 $APP_USER"
>                         sleep 30
>                         PERCENT=`prstat -u $APP_USER -t 1 1 | grep
> egatess | awk '{print $7}' | sed s/%//g`
>                         wait_count=$wait_count+1
>                         if [ $wait_count -ge 60 ]; then
>                                 #message to pager
>                                 #message to log
>                                 #exit 1
>                         fi
> 
>                         # Sleep until processes stabilize
>                 done
> 

the "top" command has this:

(/opt/sfw/bin/top)

CPU states: 93.2% idle,  0.2% user,  6.6% kernel,  0.0% iowait,  0.0% swap

Cheers,

-- 

-=//-\drian Thompson=-
0
Reply Adrian 10/27/2006 5:36:00 PM


snoopy_@excite.com <snoopy_@excite.com> wrote:
>    Prstat will provide information for each user, or process, but not
> total.   vmstat and mpstat pretty much the same.

Hmm?  It seems like vmstat *only* provides total cpu, not per processor
(mpstat) or per process (ps, prstat).

> The only thing I can
> think of is to use the output of the prstat and add the cpu totals
> together to come up with the complete total, but something tells me
> there must be a simpler way.   Any help is appreciated.  Thanks.

If you were going to do that, do it with -m added.  The kernel
maintained values are subject to certain types of errors.  With -m,
prstat uses microstate calculations and does the math itself.  Much more
accurate.

You could also use the cpu figures in 'kstat -m cpu'.  You'd need to
subtract between two collections, then sum over all the cpus and divide
by the number online.  You can gather either nsec or tick values
depending on the precision you prefer.  That will probably be easier to
parse as well.

-- 
Darren Dunham                                           ddunham@taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >
0
Reply Darren 10/27/2006 6:31:30 PM

On Fri, 27 Oct 2006, snoopy_@excite.com wrote:

>     I am trying to find a command that will provide the total CPU
> utilization for the system.   I am starting an application that has
> many processes and it's started by multiple schemas.  This same
> application has mutex problems and hold CPU's until each component
> starts successfully.   So I inserted a piece of code that executes
> "prstat -t -u username 1 1" and greps and awks the percentage our of
> the result, then if that is greater than 70% it sleeps.  Once the
> percentage drops below 70% it will continue with startup.  Just a
> simple way of throtling startup.
>    Prstat will provide information for each user, or process, but not
> total.   vmstat and mpstat pretty much the same.   The only thing I can

No, vmstat and mpstat provide info for the whole machine/zone/domain.
Why do you think they are user or process specific?

-- 
Rich Teer, SCNA, SCSA, OpenSolaris CAB member

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
0
Reply Rich 10/27/2006 6:32:37 PM

You are right, I just ignored vmstat.    I know there are accuracy
issues with it from Adrian Cockcraft's book so I'll have to test using
it vice prstat.  Thanks.

P.S.  This link speaks to some of the inaccuracy issues:
http://www.itworld.com/Net/3603/UIR980601perf/

P.P.S  System is SUN E15K, 24 CPUs

Rich Teer wrote:
> On Fri, 27 Oct 2006, snoopy_@excite.com wrote:
>
> >     I am trying to find a command that will provide the total CPU
> > utilization for the system.   I am starting an application that has
> > many processes and it's started by multiple schemas.  This same
> > application has mutex problems and hold CPU's until each component
> > starts successfully.   So I inserted a piece of code that executes
> > "prstat -t -u username 1 1" and greps and awks the percentage our of
> > the result, then if that is greater than 70% it sleeps.  Once the
> > percentage drops below 70% it will continue with startup.  Just a
> > simple way of throtling startup.
> >    Prstat will provide information for each user, or process, but not
> > total.   vmstat and mpstat pretty much the same.   The only thing I can
>
> No, vmstat and mpstat provide info for the whole machine/zone/domain.
> Why do you think they are user or process specific?
>
> --
> Rich Teer, SCNA, SCSA, OpenSolaris CAB member
>
> President,
> Rite Online Inc.
> 
> Voice: +1 (250) 979-1638
> URL: http://www.rite-group.com/rich

0
Reply snoopy_ 10/27/2006 11:35:01 PM

snoopy_@excite.com <snoopy_@excite.com> wrote:
> You are right, I just ignored vmstat.    I know there are accuracy
> issues with it from Adrian Cockcraft's book so I'll have to test using
> it vice prstat.  Thanks.

So use the kstats.  That should be making use of the microstate
accounting as far as I know.

You will have to do some math, but not too much.

-- 
Darren Dunham                                           ddunham@taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >
0
Reply Darren 10/31/2006 12:37:24 AM

snoopy_@excite.com <snoopy_@excite.com> wrote:
> P.S.  This link speaks to some of the inaccuracy issues:
> http://www.itworld.com/Net/3603/UIR980601perf/

That article is from 1998.  It's not *wrong*, but things have changed.
Microstate accounting is always on with recent releases.  You can't turn
it off, so the data is always available.

-- 
Darren Dunham                                           ddunham@taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >
0
Reply Darren 10/31/2006 1:25:52 AM

6 Replies
1221 Views

(page loaded in 0.056 seconds)

Similiar Articles:













7/20/2012 7:38:00 PM


Reply: