Solaris环境下性能采集脚本G


#--------------------------------------
#list all process start up by collectMan
#--------------------------------------
list_collect_process()
{
    echo ""
    echo "Backgroud process of collectMan:"
    ps -ef |grep collectMan|grep -v grep|grep -v list|grep -v dtpad
    echo ""
    echo "Backgroud process start up by collectMan:"
    ps -ef |/usr/xpg4/bin/grep -E 'vmstat|iostat|netstat|mpstat'|grep -v grep
    echo ""
}

#--------------------------------------
#kill all process start up by collectMan
#--------------------------------------
kill_collect_process()
{
    COLLECT_PS=`ps -ef |/usr/xpg4/bin/grep -E 'vmstat|iostat|netstat|mpstat|collectMan'|/usr/xpg4/bin/grep -vE 'grep|-kill|-q|dtpad' |awk '{print $2}'`
 
    if [ "$COLLECT_PS" = "" ]
    then
        echo "No collectMan process!"
        return 0
    else
        echo "Will kill all collectMan process: $COLLECT_PS "
    fi
   
    if [ $1 = "N" ] #if in silent mode, no need input Y
    then
        echo "Y to kill process, stop collect data! are you sure [Y/N]"
        read answer
    else
        answer="Y"
    fi
   
    if [ "$answer" = "Y" -o "$answer" = "y" ]
    then
        kill -9 $COLLECT_PS
    else
        echo "Cancel to kill collectMan."
    fi
}

#--------------------------------------
#Backup Report
#--------------------------------------
backup_report()
{
    DATE=`date +%y%m%d%H%M`
    if [ ! -d ./report/$DATE ]
    then
        mkdir ./report/$DATE
    fi
   
    mv -f ./report/*.txt ./report/$DATE
}


#--------------------------------------
#Quick mode, will backup data report and restart collectMan
#--------------------------------------
quick_mode()
{
    echo "Now use quick mode to start collectMan, will backup data report and restart collectMan process."
    kill_collect_process Y
    backup_report
    sh ./collectMan.sh $*;
}

#--------------------------------------
#set default environment
#--------------------------------------
if [ -z "$COLLECT_PERIOD" ]
then
    COLLECT_PERIOD=10
fi

COLLECT_ZIPFILE="Y"
COLLECT_NOTRUNNING_DAEMON="Y"
FILE_MAX_LENGTH=10000000
COLLECT_DEBUG="N"

#init server level data collect parameter
COLLECT_CPU="N"
COLLECT_MEMORY="N"
COLLECT_IO="N"

PATH=$PATH:/usr/bin
export PATH
COLLECT_SHOWLIST="N"

if [ ! -d ./report ]
then
    mkdir ./report
fi

猜你喜欢

转载自customer.iteye.com/blog/658166