#/bin/bash
while true
do
top -bn 1 -i -c >>./hbasemonitor/cpu.log
free >> ./hbasemonitor/meomory.log
HMasterPid=`pgrep -f HMaster`
HRegrionServerPid=`pgrep -f HRegionServer`
echo `date`"=================================" >> ./hbasemonitor/HMaster.log
echo `date`"=================================" >> ./hbasemonitor/HRegrionServer.log
if [ $HMasterPid -gt 0 ]
then
jstat -gcutil $HMasterPid 10 10 >> ./hbasemonitor/HMaster.log
jstack $HMasterPid >> ./hbasemonitor/HMaster.log
fi
if [ $HRegrionServerPid -gt 0 ]
then
jstat -gcutil $HRegrionServerPid 10 10 >>./hbasemonitor/HRegrionServer.log
jstack $HRegrionServerPid >> ./hbasemonitor/HRegrionServer.log
fi
sleep 300
done