output=/log/res.log       # Path for the log file
prc=ndsd                  # Process Name 
interval=1800             # Interval in seconds

i=0
prcid=`ps -ef | grep $prc | grep -v grep |awk '{print $2}'`

while [ $i -le 1000000 ]
do
date >> $output

echo "% CPU Utilization by $prc:---------------------------------" >> $output
top -n 1 -b | grep $prcid | awk '{print $9}' >> $output

echo "Memory Utilization by $prc:--------------------------------" >> $output
top -n 1 -b | grep $prcid | awk '{print $6}' >> $output

echo "Virtual Memory Utilization by $prc:------------------------" >> $output
top -n 1 -b | grep $prcid | awk '{print $5}' >> $output

echo "No. of Threads consumed by $prc:---------------------------" >> $output
cat /proc/$prcid/status | grep -i threads | awk '{print $2}' >> $output

echo "===========================================================" >> $output

sleep $interval
i=`expr $i + 1`
done

