性能壓測之 Memory與IO 性能數據採集

筆者在進行壓測過程當中,用shell 編寫 怎麼採集 heap 和 io 的性能數據,現分享以下:ios

loop_count=1
count=1
shell

#sleep 3ide

echo -n "Please input pid:"
read cmd1 cmd2 cmd3
oop

echo "" > heap${cmd1}.log
echo "" > heap
${cmd2}.log
echo "" > heap_${cmd3}.log
性能

fun_io() {code

echo "磁盤 I/O 採集數據開始! "
while (($loop_count <=10))
do 
   sleep 1  
   iostat -x 3 1 >> system.log 
   let "loop_count++"
done
echo "磁盤 I/0 採集數據結束!"

}input

fun_mem() {cmd

echo "HEAP 數據採集開始!"
while (($count <=3 ))
do
   sleep 5 

   if [ ${cmd1} -gt 1 ]
   then
       jmap -heap ${cmd1}  >> heap_${cmd1}.log
   else
       echo "沒有輸入pid1"
   fi

   sleep 1

   if [ ${cmd2} -gt 1 ]
   then
       jmap -heap ${cmd2}  >> heap_${cmd2}.log
   else
       echo "沒有輸入pid2"
   fi

   sleep 1

   if [ ${cmd3} -gt 1 ] 
   then
       jmap -heap ${cmd3}  >> heap_${cmd3}.log
   else
       echo "沒有輸入pid3"
   fi

   let "count++"
done
echo "HEAP 數據採集結束!"

} it

fun_io
fun_mem
io

相關文章
相關標籤/搜索