Home » Infrastructure » Unix » How to grab the list from PRSTAT output list
How to grab the list from PRSTAT output list [message #157674] Fri, 03 February 2006 14:52 Go to next message
rr9876r
Messages: 12
Registered: April 2005
Junior Member
Hi,

Here is the script I am running. I want to grab the data and display it and then grab and display it continuously.

#!/bin/ksh
while true
do
prstat -n 20 30 |awk '{printf("%s %s %s %s %s %s %s %s %s\n", $1, $2, $3, $4, $5, \
$6, $7, $8, $9)}' \
| while read PID USERNAME SIZE RSS STATE PRI NICE TIME CPU
do
echo $PID ' ' $USERNAME ' ' $SIZE ' ' $RSS ' ' $STATE ' ' $PRI ' ' $NICE
echo $TIME ' ' $CPU ' ' $PROCESS
done
done

It is continuously running without displaying the details. When I break/stop the execution, it displays all capture values.
I want to stop grabbing the data and display the results and repeat this process continuously.

Thanks for your help
Re: How to grab the list from PRSTAT output list [message #157789 is a reply to message #157674] Mon, 06 February 2006 00:53 Go to previous messageGo to next message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Are you just running the script without piping or outputting? If so, each ECHO should just display to the screen as soon as it executes.

If you are sending the output to a named pipe, and catting the named pipe to see the output, then it will buffer the output - usually in 8K buffers. This can make it seem as though its not outputting until the end.

Otherwise, there may be some obscure STTY setting that causes STDOUT to be buffered (but I've never seen it happen).
_____________
Ross Leishman
Re: How to grab the list from PRSTAT output list [message #157843 is a reply to message #157789] Mon, 06 February 2006 10:47 Go to previous message
rr9876r
Messages: 12
Registered: April 2005
Junior Member
Actually, I want check which process is taking more CPU time and logon to Oracle database to find the SQL statement and send the email to me. I want to add code later within the inner 'do ...done' loop. I know PRSTAT runs continuously and grabs the data, after grabbing the data I want to see which process id is taking more CPU time
Previous Topic: Errors when trying to run korn shell script
Next Topic: Sun Cluster and listener.ora configuration
Goto Forum:
  


Current Time: Mon Nov 25 17:15:08 CST 2024