Capture PRSTAT


 
Thread Tools Search this Thread
Operating Systems Solaris Capture PRSTAT
# 1  
Old 02-06-2015
Capture PRSTAT

Is there any scripts to capture the process which use more than 5% CPU from prstat output?
# 2  
Old 02-06-2015
Probably something like this should do:
Code:
prstat|awk '{ if ($9 >= 5) print $0 }'

# 3  
Old 02-06-2015
Quote:
Originally Posted by Walter Misar
Probably something like this should do:
Code:
prstat|awk '{ if ($9 >= 5) print $0 }'

I don't have prstat on my system, but, you'll probably need something more like:
Code:
prstat|awk '{ if (($9+0) >= 5) print $0 }'

to be sure you get a numeric comparison rather than a string comparison.

And, if that works, you can shorten the above script to:
Code:
prstat|awk '($9+0) >= 5'

since the default action in an awk statement with an expression that evaluates to TRUE is to print the input line.
# 4  
Old 02-06-2015
One other point

prstat with no interval and count runs until you type ctrl/c or something else stops the process.

Code:
prstat 5 5

runs for 25 seconds.

If you want to "log" data from a entire day, you may want to use other tools. Consider enabling sar as a starting point.

IMO, a single snapshot of prstat does not give you much to go on. You have to proceed on to other tools, like iostat, fsstat, vmstat, or maybe dtrace. sar gets you further down the road to solving performance problems right from the beginning. And with sar you have a sort of running history to see episodic symptoms.
# 5  
Old 02-06-2015
Here is a variant of what was already suggested.

It increases from 15 to 20 the number of processes to check in order to make sure no process is left out, it filters out lines not showing processes but the load average in the 9th column and it uses the right Solaris awk implementation:
Code:
prstat -c -n 20 | nawk '$9 ~ "%" && $9 >= 5'

If you are running Solaris 11, here is a way to prepend a timestamp to the output:
Code:
prstat -d u -c -n 20 | nawk 'NF == 1 { ts=$1 } $9 ~ "%" && $9 >= 5 { print ts , $0 }'

# 6  
Old 02-07-2015
Quote:
Originally Posted by jim mcnamara
One other point

prstat with no interval and count runs until you type ctrl/c or something else stops the process.

Code:
prstat 5 5

runs for 25 seconds.

If you want to "log" data from a entire day, you may want to use other tools. Consider enabling sar as a starting point.

IMO, a single snapshot of prstat does not give you much to go on. You have to proceed on to other tools, like iostat, fsstat, vmstat, or maybe dtrace. sar gets you further down the road to solving performance problems right from the beginning. And with sar you have a sort of running history to see episodic symptoms.
Hi Jim Mcnamara,
thanks for your reply. Can you help to elaborate on how to run SAR to troubleshoot performance issue?
# 7  
Old 02-07-2015
The advantage of sar is that is automatize statistical captures and allow displaying them later. However, it targets system performance and isn't going to help that much figuring out which process is responsible of a performance issue.

Note also that a process using more than 5% of the CPU capacity is far for being an issue. A process using 100% of the CPU(s) might not be even one, that's why you buy CPUs after all. There are more relevant metrics.

I would suggest you to read this Solaris documentation:
Monitoring System Performance (Tasks) - Oracle Solaris Administration: Common Tasks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Solaris

Understanding prstat

Hello We have a SPARC box running Solaris 10. We have 32 GB of physical memory, 32 GB of swap. Now i want to monitor memory usage for performance tuning. The box is running Sybase database. When I type prstat i get the following PID USERNAME SIZE RSS STATE PRI NICE TIME CPU... (4 Replies)
Discussion started by: abohmeed
4 Replies

3. Shell Programming and Scripting

prstat output

hi all, have a ksh script where i am doing a prstat -m -u osuser 1 1 >> $FILE_NAME but for some reason it only writes 15 lines wheres when i run the same command manually from command prompt it prints out 60 lines. why is it not writing the full 60 lines to the file ?? ta. (1 Reply)
Discussion started by: cesarNZ
1 Replies

4. Solaris

prstat

hi all, was trying to figure out how busy my app was by looking at the performance of the app server. did a 'prstat -s rss' command to find the app servers using most memory. Found a command 'prstat -m' which is meant to show more details on each pid but the output of this command... (1 Reply)
Discussion started by: cesarNZ
1 Replies

5. Shell Programming and Scripting

prstat

hi all, am writing a ksh script on solaris 9 to get the number of threads taken by a process. am using the prstat -p command to do this. output i get is : :"/export/home/user" > prstat -p 25528 | cut -f2 -d/ NLWP 203 Total: 1 processes, 203 lwps, load averages: 2.58, 3.24, 3.62... (2 Replies)
Discussion started by: cesarNZ
2 Replies

6. Solaris

prstat output

Can someone please explain me the "TIME" field of the output of "prstat -p<pid>" command ? The man page says it is "The cumulative execution time for the process". Does it mean how many hrs:min:sec the process is running ? If so then I'm not getting the desired output. Can someone pls help me in... (5 Replies)
Discussion started by: senabhi
5 Replies

7. Shell Programming and Scripting

prstat output in GB

Hi, Is there any way by which the unit of size and rss will be only GB while I am running the prstat command? (2 Replies)
Discussion started by: King Nothing
2 Replies

8. Solaris

prstat O/P

Good Evening everyone, I am confused about prstat O/P as it shows memory values which are different from actual value.Below is the O/P of prstat command and swap commands. NPROC USERNAME SIZE RSS MEMORY TIME CPU 48 root 2113M 1590M 1.2% 45:09.39 32% 31 daemon ... (7 Replies)
Discussion started by: vvpotugunta
7 Replies

9. Shell Programming and Scripting

prstat problem

This will be a smaple output for my prstat -t NPROC USERNAME SIZE RSS MEMORY TIME CPU 43 root 249M 62M 1.5% 33:50:01 0.1% 12 oadmin 1396M 862M 22% 0:06:49 0.1% 2 acne 3960K 3176K 0.1% 0:00:00 0.0% 4 essagent 10M 7456K 0.2% 0:00:00 0.0%... (6 Replies)
Discussion started by: vivsiv
6 Replies

10. UNIX for Dummies Questions & Answers

Help with prstat

Hello, The last line of prstat shows load average. I am unable to figure out what actually it is. I have read the man pages and also googled, all for no use. Can somebody help me, as to what should be the avg. load of the system for best performance and how is this load of prstat calculated. (6 Replies)
Discussion started by: vibhor_agarwali
6 Replies
Login or Register to Ask a Question