Unix command to find CPU Utilization

Q. I am using Solaris UNIX. How do I find out CPU Utilization under Sun Solaris UNIX?

ADVERTISEMENTS

A. Under Sun Solaris UNIX (and other UNIX oses like HP-UX and *BSD oses) you can use following commands to gather CPU information:

=> sar : System activity reporter

=> mpstat : Report per-processor or per-processor-set statistics

=> ps / top commands

Note: Linux specific CPU utilization information is here. Following information applies to UNIX only.

UNIX sar command examples

General syntax is as follows:
sar t [n]
In the first instance, sar samples cumulative activity counters in the operating system at n intervals of t seconds, where t should be 5 or greater. If t is specified with more than one option, all headers are printed together and the output may be difficult to read.

Task: Display today’s CPU activity, use

# sar

Task:Watching system activity evolve i.e. reports CPU Utilization

# sar -u 12 5

Where,

  • -u 12 5: Comparison of CPU utilization; 12 seconds apart; 5 times.

Output includes:

  1. %usr: User time (% of CPU)
  2. %sys: System time (% of CPU)
  3. %wio: Percent of CPU running idle with a process waiting for block I/O
  4. %idle: Percent of CPU that is idle

Task: You can watch CPU activity evolve for 10 minutes and save data

# sar -o file-name 60 10

Task: You can just sar and logout and let the report store in files

# nohup sar -A -o output-file 60 10 1>/dev/null 2>&1 &
Note to display data stored in output-file pass -f option to sar command:
# sar -f output-file

UNIX mpstat example

Type the following command to display per-processor statistics; 12 seconds apart; 5 times
# mpstat 12 5

You can also use traditional ps and top command:
# top
# ps -e -o pcpu -o pid -o user -o args

Read man pages of ps, top, mpstat and sar for more information.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
14 comments… add one
  • varun Sep 20, 2007 @ 9:57

    i want to learn linux this is very useful and powerful compare to Windows.

  • Sadequl Ghani Feb 12, 2008 @ 10:15

    How to install pine in Sun Solaris 10.5 under UNIX env?

  • lokesh Jul 9, 2010 @ 10:49

    I have Unix system with 32 CPU and 32 GB memory. My application is installed on Websphere. Looks like only 1 processor is allocated to my application out of 32 cpu. Is it possible to allocate multiple processors for my application. The system always shows 90% CPU idle time and more than 20 G free memory. How can I utilise this memory and cpu time to get better performance.

    • drdaco Sep 9, 2010 @ 19:40

      Lokesh,

      Unless your application is already parallelized, there is no way to force it to use more than one CPU. Do you know if your application is Serial or in Parallel?

  • satish kuchoor Apr 18, 2011 @ 8:01

    what is the commandin UNIX SOLARIS to list out 5 TOP processors which is consuming more CUP

    • pravar Jun 16, 2011 @ 9:09

      the command is ‘top’.

  • Sneha Jul 14, 2011 @ 5:46

    How to check the average of last 12 hrs CPU usage

  • rajesh Jan 27, 2012 @ 11:21

    i have 42 cpus and 256 gb ram… i want to run my job autometically when my cpus usage is below cetain limit

  • jocuri actiune Mar 14, 2012 @ 8:50

    i have 12 cpus and 256 gb ram… i want to run my job when my cpus usage is below cetain limit

  • satya Jul 23, 2012 @ 13:01

    top|grep “Cpu(s):”|awk ‘{ print $2 }’| head -1

    Above command will get the cCPU usgae.

  • joy Oct 3, 2012 @ 8:05

    top -n 1 | grep Cpu | awk ‘{print $2 }’
    Output: 0.2%us,

  • GOBI NATH Jan 20, 2013 @ 8:35

    I need Some HC Commands. pls share some useful command’s

  • satya Jan 21, 2013 @ 11:41

    top | grep “process name”
    it s a simple command to fetch exact process utilization

  • dermecure Jul 27, 2015 @ 14:16

    i need a command to fetch the list of cpu utilization from a particular user

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.