{"id":4728,"date":"2015-05-08T10:01:43","date_gmt":"2015-05-08T02:01:43","guid":{"rendered":"http:\/\/rmohan.com\/?p=4728"},"modified":"2015-05-08T10:43:28","modified_gmt":"2015-05-08T02:43:28","slug":"solaris-command-prstat","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=4728","title":{"rendered":"Solaris command: prstat"},"content":{"rendered":"<h3>Total Physical Memory<\/h3>\n<ol>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div>&gt;prtdiag -v | grep Memory<\/div>\n<\/li>\n<li>\n<div>Memory size: 8192 Megabytes<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div>&gt;prtconf | grep Memory<\/div>\n<\/li>\n<li>\n<div>Memory size: 8192 Megabytes<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<\/ol>\n<h3>Total Physical Memory<\/h3>\n<ol>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div>&gt;vmstat 5 10<\/div>\n<\/li>\n<li>\n<div>r b w swap free re mf pi po fr de sr vc vc vc vc in sy cs us sy id<\/div>\n<\/li>\n<li>\n<div>0 0 0 14841224 772880 23 147 19 6 6 0 1 1 0 2 2 3775 2990 3820 2 2 96<\/div>\n<\/li>\n<li>\n<div>1 0 0 20482808 4992304 3 3 0 0 0 0 0 1 0 0 0 527 474 482 13 0 87<\/div>\n<\/li>\n<li>\n<div>0 0 0 20483192 5000272 1 5 0 3 3 0 0 0 0 0 1 583 645 606 13 1 86<\/div>\n<\/li>\n<li>\n<div>0 0 0 20485848 5033400 0 0 0 0 0 0 0 0 0 0 0 528 463 492 13 1 86<\/div>\n<\/li>\n<li>\n<div>0 0 0 20485848 5033344 0 0 0 0 0 0 0 0 0 0 1 514 469 475 13 0 87<\/div>\n<\/li>\n<li>\n<div>0 0 0 20485848 5033288 0 0 0 0 0 0 0 0 0 0 2 513 450 476 13 0 87<\/div>\n<\/li>\n<li>\n<div>0 0 0 20485848 5033288 0 0 0 0 0 0 0 1 0 0 0 516 468 476 13 0 87<\/div>\n<\/li>\n<li>\n<div>0 0 0 20485848 5033240 0 0 0 0 0 0 0 0 0 0 0 510 451 467 13 0 87<\/div>\n<\/li>\n<li>\n<div>0 0 0 20485848 5033184 0 0 0 0 0 0 0 0 0 0 0 518 468 475 13 0 87<\/div>\n<\/li>\n<li>\n<div>0 0 0 20485848 5033128 0 0 0 0 0 0 0 0 0 0 0 523 456 474 13 1 86<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<\/ol>\n<h3>Find Overall CPU Usages<\/h3>\n<p>* Use multiple processor stat tool &#8216;mpstat&#8217;<br \/>\n* Columns to note<br \/>\n&#8211; &#8216;usr&#8217;: percent user time<br \/>\n&#8211; &#8216;sys&#8217;: percent system time<br \/>\n&#8211; &#8216;idl&#8217;: percent idle time<br \/>\n* Example<\/p>\n<ol>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div># Generate 2 processor reports with 5 second interval<\/div>\n<\/li>\n<li>\n<div>mpstat 5 2<\/div>\n<\/li>\n<li>\n<div>CPU minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl<\/div>\n<\/li>\n<li>\n<div>0 14 0 42 35 18 48 0 1 8 0 139 1 0 0 99<\/div>\n<\/li>\n<li>\n<div>1 7 0 27 87 55 65 0 1 8 0 92 0 1 0 99<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<\/ol>\n<h3>Find CPU Usage by Processes<\/h3>\n<p>* Use process stat tool &#8216;prstat&#8217;<br \/>\n* Similar to Linux &#8216;top&#8217; command<br \/>\n* Examples<\/p>\n<ol>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div># Sort by cpu usage (default)<\/div>\n<\/li>\n<li>\n<div>prstat<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div># Sort by memory usage<\/div>\n<\/li>\n<li>\n<div>prstat -s rss<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div># Sort by virtual memory usage<\/div>\n<\/li>\n<li>\n<div>prstat -s size<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div># Sort by process execution time<\/div>\n<\/li>\n<li>\n<div>prstat -s time<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div># Find top 5 processes<\/div>\n<\/li>\n<li>\n<div>prstat -n 5<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div># Also print process numbers each user is using<\/div>\n<\/li>\n<li>\n<div>prstat -a<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div># Follow a particular process id<\/div>\n<\/li>\n<li>\n<div>prstat -p pid<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div># Follow threads of a particular process id<\/div>\n<\/li>\n<li>\n<div>prstat -L -p pid<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<\/ol>\n<h3>Find Paging Activities<\/h3>\n<p>* Use system activity report tool &#8216;sar&#8217;<br \/>\n* Examples<\/p>\n<ol>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div># Find top 3 paging activities with 5 second interval<\/div>\n<\/li>\n<li>\n<div>sar -g 5 3<\/div>\n<\/li>\n<li>\n<div>18:57:12 pgout\/s ppgout\/s pgfree\/s pgscan\/s %ufs_ipf<\/div>\n<\/li>\n<li>\n<div>18:57:17 0.00 0.00 0.00 0.00 0.00<\/div>\n<\/li>\n<li>\n<div>18:57:22 0.00 0.00 0.00 0.00 0.00<\/div>\n<\/li>\n<li>\n<div>18:57:27 0.00 0.00 0.00 0.00 0.00<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div>Average 0.00 0.00 0.00 0.00 0.00<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div># Total memory<\/div>\n<\/li>\n<li>\n<div>\/usr\/sbin\/prtconf | grep Memory | awk -F&#8221;:&#8221; &#8216;{print $2}&#8217;<\/div>\n<\/li>\n<li>\n<div>Memory size: 8192 Megabytes<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div># Find free memory and swap space based on 3 reads with 5 second read intervals<\/div>\n<\/li>\n<li>\n<div>sar -r 5 3<\/div>\n<\/li>\n<li>\n<div>18:56:24 freemem freeswap<\/div>\n<\/li>\n<li>\n<div>18:56:29 175049 28289968<\/div>\n<\/li>\n<li>\n<div>18:56:34 175031 28289843<\/div>\n<\/li>\n<li>\n<div>18:56:39 175026 28289952<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div>Average 175036 28289921<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<\/ol>\n<h3>Process Memory Usage<\/h3>\n<ol>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div>&gt;ps -A -o pmem -o pcpu -o args<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div>&gt;ps -e -o &#8220;rss(k) vsz(k) pmem pid comm&#8221; | qrep -v COMMAND | sort -rn | awk &#8216;{print $1 &#8220;\\t&#8221; $2 &#8220;\\t&#8221; $3 &#8220;\\t&#8221; $4 &#8220;\\t&#8221; $5;}&#8217;<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<\/ol>\n<h3>Sample Sessions<\/h3>\n<p>* Follow a particular process id in 5 second intervals and send result to server.out file<\/p>\n<ol>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div>bash-3.00$ prstat -L -p 16401 5 &gt; server.out &amp;<\/div>\n<\/li>\n<li>\n<div>[1] 16530<\/div>\n<\/li>\n<li>\n<div>bash-3.00$ tail -f server.out<\/div>\n<\/li>\n<li>\n<div>PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS\/LWPID<\/div>\n<\/li>\n<li>\n<div>16401 oracle 5270M 4125M sleep 59 0 0:00:00 0.0% oracle\/1<\/div>\n<\/li>\n<li>\n<div>Total: 1 processes, 1 lwps, load averages: 0.03, 0.04, 0.04<\/div>\n<\/li>\n<li>\n<div>PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS\/LWPID<\/div>\n<\/li>\n<li>\n<div>16401 oracle 5270M 4125M sleep 59 0 0:00:00 0.0% oracle\/1<\/div>\n<\/li>\n<li>\n<div>Total: 1 processes, 1 lwps, load averages: 0.03, 0.04, 0.04<\/div>\n<\/li>\n<li>\n<div>PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS\/LWPID<\/div>\n<\/li>\n<li>\n<div>16401 oracle 5270M 4125M sleep 59 0 0:00:00 0.0% oracle\/1<\/div>\n<\/li>\n<li>\n<div>Total: 1 processes, 1 lwps, load averages: 0.03, 0.04, 0.04<\/div>\n<\/li>\n<li>\n<div>PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS\/LWPID<\/div>\n<\/li>\n<li>\n<div>16401 oracle 5270M 4125M sleep 59 0 0:00:00 0.0% oracle\/1<\/div>\n<\/li>\n<li>\n<div>Total: 1 processes, 1 lwps, load averages: 0.03, 0.04, 0.04<\/div>\n<\/li>\n<li>\n<div>^C<\/div>\n<\/li>\n<li>\n<div>bash-3.00$ jobs<\/div>\n<\/li>\n<li>\n<div>[1]+ Running prstat -L -p 16401 5 &gt;server.out &amp;<\/div>\n<\/li>\n<li>\n<div>bash-3.00$ fg %1<\/div>\n<\/li>\n<li>\n<div>prstat -L -p 16401 5 &gt;server.out<\/div>\n<\/li>\n<li>\n<div>^C<\/div>\n<\/li>\n<li>\n<div>bash-3.00$<\/div>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Total Physical Memory &gt;prtdiag -v | grep Memory Memory size: 8192 Megabytes &gt;prtconf | grep Memory Memory size: 8192 Megabytes Total Physical Memory &gt;vmstat 5 10 r b w swap free re mf pi po fr de sr vc vc vc vc in sy cs us sy id 0 0 0 14841224 772880 23 147 [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4728"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4728"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4728\/revisions"}],"predecessor-version":[{"id":4729,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4728\/revisions\/4729"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}