output=/log/OS-Res.log #Log file path
prt1=389 #Port Number to monitor the number of connections
prt2=636 #Port Number to monitor the number of connections
interval=1800 #Interval in seconds

i=0
while [ $i -le 1000000 ]
do
date >> $output

echo "netstat-$prt1:" >> $output
netstat -na|grep $prt1 | grep -i established | wc -l >> $output
echo "-------------------------------------------------------------" >> $output

echo "netstat-$prt2:" >> $output
netstat -na|grep $prt2 | grep -i established | wc -l >> $output
echo "-------------------------------------------------------------" >> $output

echo "vmstat:" >> $output
vmstat >> $output
echo "-------------------------------------------------------------" >> $output

echo "mpstat:" >> $output
mpstat >> $output
echo "-------------------------------------------------------------" >> $output

echo "iostat:" >> $output
iostat >> $output
echo "=============================================================" >> $output

sleep $interval
i=`expr $i + 1`
done

