首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > 其他服务器 >

Solaris环境上性能采集脚本G

2012-07-22 
Solaris环境下性能采集脚本G#--------------------------------------#list all process start up by coll

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

热点排行