{"id":1967,"date":"2011-02-23T11:28:12","date_gmt":"2011-02-23T16:28:12","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=1967"},"modified":"2011-06-08T13:40:18","modified_gmt":"2011-06-08T18:40:18","slug":"solaris-command-prstat","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=1967","title":{"rendered":"Solaris command: prstat"},"content":{"rendered":"<span id=\"Total_Physical_Memory\"><h3>Total Physical Memory<\/h3><\/span>\n<pre lang=\"bash\">\r\n>prtdiag -v | grep Memory\r\nMemory size: 8192 Megabytes\r\n\r\n>prtconf | grep Memory\r\nMemory size: 8192 Megabytes\r\n<\/pre>\n<span id=\"Total_Physical_Memory_1\"><h3>Total Physical Memory<\/h3><\/span>\n<pre lang=\"bash\">\r\n>vmstat 5 10\r\n r b w   swap  free  re  mf pi po fr de sr vc vc vc vc   in   sy   cs us sy id\r\n 0 0 0 14841224 772880 23 147 19 6 6  0  1  1  0  2  2 3775 2990 3820  2  2 96\r\n 1 0 0 20482808 4992304 3 3  0  0  0  0  0  1  0  0  0  527  474  482 13  0 87\r\n 0 0 0 20483192 5000272 1 5  0  3  3  0  0  0  0  0  1  583  645  606 13  1 86\r\n 0 0 0 20485848 5033400 0 0  0  0  0  0  0  0  0  0  0  528  463  492 13  1 86\r\n 0 0 0 20485848 5033344 0 0  0  0  0  0  0  0  0  0  1  514  469  475 13  0 87\r\n 0 0 0 20485848 5033288 0 0  0  0  0  0  0  0  0  0  2  513  450  476 13  0 87\r\n 0 0 0 20485848 5033288 0 0  0  0  0  0  0  1  0  0  0  516  468  476 13  0 87\r\n 0 0 0 20485848 5033240 0 0  0  0  0  0  0  0  0  0  0  510  451  467 13  0 87\r\n 0 0 0 20485848 5033184 0 0  0  0  0  0  0  0  0  0  0  518  468  475 13  0 87\r\n 0 0 0 20485848 5033128 0 0  0  0  0  0  0  0  0  0  0  523  456  474 13  1 86\r\n<\/pre>\n<span id=\"Find_Overall_CPU_Usages\"><h3>Find Overall CPU Usages<\/h3><\/span>\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<pre lang=\"bash\">\r\n# Generate 2 processor reports with 5 second interval\r\nmpstat 5 2\r\nCPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl\r\n  0   14   0   42    35   18   48    0    1    8    0   139    1   0   0  99\r\n  1    7   0   27    87   55   65    0    1    8    0    92    0   1   0  99\r\n<\/pre>\n<span id=\"Find_CPU_Usage_by_Processes\"><h3>Find CPU Usage by Processes<\/h3><\/span>\n<p>* Use process stat tool &#8216;prstat&#8217;<br \/>\n* Similar to Linux &#8216;top&#8217; command<br \/>\n* Examples<\/p>\n<pre lang=\"bash\">\r\n# Sort by cpu usage (default)\r\nprstat \r\n\r\n# Sort by memory usage\r\nprstat -s rss\r\n\r\n# Sort by virtual memory usage\r\nprstat -s size\r\n\r\n# Sort by process execution time\r\nprstat -s time\r\n\r\n# Find top 5 processes\r\nprstat -n 5\r\n\r\n# Also print process numbers each user is using\r\nprstat -a\r\n\r\n# Follow a particular process id\r\nprstat -p pid\r\n\r\n# Follow threads of a particular process id\r\nprstat -L -p pid\r\n<\/pre>\n<span id=\"Find_Paging_Activities\"><h3>Find Paging Activities<\/h3><\/span>\n<p>* Use system activity report tool &#8216;sar&#8217;<br \/>\n* Examples<\/p>\n<pre lang=\"bash\">\r\n# Find top 3 paging activities with 5 second interval\r\nsar -g 5 3\r\n18:57:12  pgout\/s ppgout\/s pgfree\/s pgscan\/s %ufs_ipf\r\n18:57:17     0.00     0.00     0.00     0.00     0.00\r\n18:57:22     0.00     0.00     0.00     0.00     0.00\r\n18:57:27     0.00     0.00     0.00     0.00     0.00\r\n\r\nAverage      0.00     0.00     0.00     0.00     0.00\r\n\r\n# Total memory\r\n\/usr\/sbin\/prtconf | grep Memory | awk -F\":\" '{print $2}'\r\nMemory size: 8192 Megabytes\r\n\r\n# Find free memory and swap space based on 3 reads with 5 second read intervals\r\nsar -r 5 3\r\n18:56:24 freemem freeswap\r\n18:56:29  175049 28289968\r\n18:56:34  175031 28289843\r\n18:56:39  175026 28289952\r\n\r\nAverage   175036 28289921\r\n<\/pre>\n<span id=\"Process_Memory_Usage\"><h3>Process Memory Usage<\/h3><\/span>\n<pre lang=\"bash\">\r\n>ps -A -o pmem -o pcpu -o args\r\n\r\n>ps -e -o \"rss(k) vsz(k) pmem pid comm\" | qrep -v COMMAND | sort -rn | awk '{print $1 \"\\t\" $2 \"\\t\" $3 \"\\t\" $4 \"\\t\" $5;}'\r\n<\/pre>\n<span id=\"Sample_Sessions\"><h3>Sample Sessions<\/h3><\/span>\n<p>* Follow a particular process id in 5 second intervals and send result to server.out file<\/p>\n<pre lang=\"bash\">\r\nbash-3.00$ prstat -L -p 16401 5 > server.out &\r\n[1] 16530\r\nbash-3.00$ tail -f server.out \r\n   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS\/LWPID      \r\n 16401 oracle   5270M 4125M sleep   59    0   0:00:00 0.0% oracle\/1\r\nTotal: 1 processes, 1 lwps, load averages: 0.03, 0.04, 0.04\r\n   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS\/LWPID      \r\n 16401 oracle   5270M 4125M sleep   59    0   0:00:00 0.0% oracle\/1\r\nTotal: 1 processes, 1 lwps, load averages: 0.03, 0.04, 0.04\r\n   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS\/LWPID      \r\n 16401 oracle   5270M 4125M sleep   59    0   0:00:00 0.0% oracle\/1\r\nTotal: 1 processes, 1 lwps, load averages: 0.03, 0.04, 0.04\r\n   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS\/LWPID      \r\n 16401 oracle   5270M 4125M sleep   59    0   0:00:00 0.0% oracle\/1\r\nTotal: 1 processes, 1 lwps, load averages: 0.03, 0.04, 0.04\r\n^C\r\nbash-3.00$ jobs\r\n[1]+  Running                 prstat -L -p 16401 5 >server.out &\r\nbash-3.00$ fg %1\r\nprstat -L -p 16401 5 >server.out\r\n^C\r\nbash-3.00$ \r\n<\/pre>\n<span id=\"References\"><h3>References<\/h3><\/span>\n<p>* <a href=\"http:\/\/developers.sun.com\/solaris\/articles\/prstat.html\">Topping top in Solaris 8 with prstat<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Total Physical Memory >prtdiag -v | grep Memory Memory size: 8192 Megabytes >prtconf | grep Memory Memory size: 8192 Megabytes Total Physical Memory >vmstat 5 10 r b w swap free re mf pi po fr de sr vc vc &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=1967\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[45],"tags":[],"class_list":["post-1967","post","type-post","status-publish","format-standard","hentry","category-solaris"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-vJ","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1967","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1967"}],"version-history":[{"count":5,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1967\/revisions"}],"predecessor-version":[{"id":2035,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1967\/revisions\/2035"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1967"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1967"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1967"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}