prstat in shell | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

prstat in shell

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-06-2007
madmat madmat is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 17 December 2013, 9:47 AM EST
Location: Paris
Posts: 97
Thanks: 0
Thanked 1 Time in 1 Post
prstat in shell

Hello,

How can I do to use prstat command in a korn-shell ?

Thanks a lot.
Rgds.
Sponsored Links
    #2  
Old 02-06-2007
sb008 sb008 is offline Forum Advisor  
Registered User
 
Join Date: Jan 2007
Last Activity: 12 January 2013, 3:37 AM EST
Posts: 398
Thanks: 1
Thanked 3 Times in 3 Posts
Just type prstat on the command line and press enter.

If you get an error message saying something like "prstat: command not found" check your PATH environment variable to see if the directory in which prstat is located is included in the PATH

echo $PATH

Or, do you have a question about how to process the output of prstat in a specific way?
Sponsored Links
    #3  
Old 02-06-2007
madmat madmat is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 17 December 2013, 9:47 AM EST
Location: Paris
Posts: 97
Thanks: 0
Thanked 1 Time in 1 Post
Exactly, I just want to launch prstat and use the output inside a shell.
    #4  
Old 02-06-2007
sb008 sb008 is offline Forum Advisor  
Registered User
 
Join Date: Jan 2007
Last Activity: 12 January 2013, 3:37 AM EST
Posts: 398
Thanks: 1
Thanked 3 Times in 3 Posts
If you check the manual page for prstat you will see that besided a lot of options there are 2 optional arguments for prstat.

These arguments are:
interval (interval in seconds between 2 statistics reports)
count (Number of statistics reports)

So you could use:

prstat 2 5
Make 5 statistics reports with an interval of 2 seconds

prtstat 3
Make endless statistics report with an interval of 3 seconds.

prstat 0 1
Make 1 statistics report with an interval of 0 seconds (The interval is irrelevant here and can be any number, since it's only 1 report).


To process the output of prstat in a scriipt you have to limit the number of statistics reports. Without this limitation prstat would never end and your script with never proceeed.

You can redirect the limited number of statistics reports to some kind of file which you use later on in your script as source to extract/generate/manipulate or whatever.

If you do not which to redirect the output to a file but like to process the outut right away, by piping the output to another command, it would be easiest to start with a single statistics report. Once you know how to parse that kind of information e.g. with (n)awk you count increase the number of statistics reports. But no matter what, make sure the number of statistics reports is limited, or your script will never end.

There are ways to process a continious output stream of prstat, but shell scripting is not really suited for that. Basically you would have 2 programs and are dealing with IPC (Inter Process Communication).
Sponsored Links
    #5  
Old 02-07-2007
madmat madmat is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 17 December 2013, 9:47 AM EST
Location: Paris
Posts: 97
Thanks: 0
Thanked 1 Time in 1 Post
Very good.
It works fine !
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
prstat with ksh pointer Shell Programming and Scripting 4 06-20-2010 11:20 AM
prstat cesarNZ Solaris 1 09-10-2009 05:52 PM
prstat log dipashre Solaris 10 10-27-2008 08:27 AM
stop Prstat using shell script filthymonk Shell Programming and Scripting 19 05-23-2007 05:24 AM
Help with prstat vibhor_agarwali UNIX for Dummies Questions & Answers 6 04-07-2005 08:01 AM



All times are GMT -4. The time now is 08:58 AM.