prstat with ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting prstat with ksh
# 1  
Old 06-20-2010
prstat with ksh

trying to have prstat into a file on a Solaris machine.
Would like to have the prstat run from a cron every 30 min.
print 300 lines+ date.
Date is not printed, only the prstat, and ksh does not end, it stays running...

Code:
#!/bin/ksh
# ----------------------------------------------------
# capture_prstat.sh    <INTERVAL> <COUNT>
# run prstat and capture output to a log file
#-----------------------------------------------------
#
# scripts and logs are stored
export PROGDIR=/var/tmp/XXX/scripts
export LOGDIR=/var/tmp/XXX/logs

# logfile name and location
export LOG_FILE=${LOGDIR}/capture_prstat.${LOGNAME}.log

# write current date/time to log file
echo "#--- $(date---)"        >> ${LOG_FILE}
    
for  PID in `ps -ef|grep XXX|grep -v grep |awk '{print $2}'`; do
            prstat -L -p $PID -v -c -n1,1 >> /var/tmp/XXX/capture_prstat.log
done;


Last edited by radoulov; 06-20-2010 at 11:37 AM.. Reason: Please use code tags!
# 2  
Old 06-20-2010
change
Code:
prstat -L -p $PID -v -c -n1,1 >> /var/tmp/XXX/capture_prstat.log

to
Code:
prstat -L -p $PID -v -c -n1,1 1 1 >> /var/tmp/XXX/capture_prstat.log

# 3  
Old 06-20-2010
update

what does the change should do?
I guess im missing something.
ouput file:
bash-3.00$ less capture_prstat.xxx.log
#---
#---
#---
# 4  
Old 06-20-2010
Change
Code:
echo "#--- $(date---)"        >> ${LOG_FILE}

to
Code:
echo "#--- $(date) ---"        >> ${LOG_FILE}

date--- is an unknown command.
# 5  
Old 06-20-2010
Many thanks, works great, all is required is to put it into the cron.
was never expected for such prompt respons. most helpfull.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Capture PRSTAT

Is there any scripts to capture the process which use more than 5% CPU from prstat output? (9 Replies)
Discussion started by: tharmendran
9 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. UNIX for Dummies Questions & Answers

help to parse prstat -t

prstat -t -n 10 1 5 NPROC USERNAME SWAP RSS MEMORY TIME CPU 143 sbswrk1 2082M 2139M 3.3% 801:46:08 1.0% 26 sbswrk3 4573M 4675M 7.1% 651:28:35 0.8% 35 sbswrk2 3922M 4004M 6.1% 1000:53:1 0.1% 4 svcbmcp 47M 52M 0.1% 256:25:24 0.1% 78 root 352M ... (1 Reply)
Discussion started by: madfox
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 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

7. Solaris

prstat log

Hi All, But the prstat logs of my system shows:- NPROC USERNAME SWAP RSS MEMORY TIME CPU 77 oracle 17G 10G 65% 4:24:47 0.8% Total: 486 processes, 3850 lwps, load averages: 3.77, 4.45, 4.94 What does the MEMORY denotes? Is it the %memory used from RAM? Or is the %memory used by... (10 Replies)
Discussion started by: dipashre
10 Replies

8. Solaris

prstat log

Hi All, Operating System and Version: SunOS,Solaris 10 sparc(64 bit) RDBMS Version: 10.2.0.4.0 But the prstat logs of my system shows:- NPROC USERNAME SWAP RSS MEMORY TIME CPU 83 cemsbin 5204M 3604M 22% 53:46:00 6.7% 2 adm 244M 240M 1.5% 15:13:53 3.5% 77 oracle 17G 10G 65% 4:24:47... (0 Replies)
Discussion started by: dipashre
0 Replies

9. Shell Programming and Scripting

prstat in shell

Hello, How can I do to use prstat command in a korn-shell ? Thanks a lot. Rgds. (4 Replies)
Discussion started by: madmat
4 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