output=/log/res.log       # Path for the log file
prc=ndsd                  # Process Name 
interval=1800             # interval in seconds

i=0
prcid=`pgrep $prc`

while [ $i -le 1000000 ]
do
date >> $output

echo "% CPU Utilization by $prc:---------------------------------" >> $output
top -n 120 -b | grep $prcid | awk '{print $10}' >> $output

echo "Memory Utilization by $prc:--------------------------" >> $output
top -n 120 -b | grep $prcid | awk '{print $7}' >> $output

echo "Virtual Memory Utilization by $prc:------------------" >> $output
top -n 120 -b | grep $prcid | awk '{print $6}' >> $output

echo "No. of Threads consumed by $prc:---------------------------" >> $output
top -n 120 -b | grep $prcid | awk '{print $3}' >> $output

echo "===========================================================" >> $output

sleep $interval
i=`expr $i + 1`
done

