六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 104|回复: 0

Solaris环境下性能采集脚本C

[复制链接]

升级  67.67%

123

主题

123

主题

123

主题

举人

Rank: 3Rank: 3

积分
403
 楼主| 发表于 2013-1-28 23:52:26 | 显示全部楼层 |阅读模式
#--------------------------------------
#Show simple usage information
#--------------------------------------
usage()
{
echo "Usage:    sh ./collectMan.sh [-process] processName [-cpu] [-memory] [-diskio] diskName [-net] netif [-summary]"
echo "Example:  sh ./collectMan.sh -q -period 10 -process dataserver IPMSDm DCServer EnpowerDm -cpu -memory -diskio c1t0d0s0 c1t1d0s6 c1t2d0s6 -net -summary"
echo "!!! For simply use, just input 'sh ./collectMan.sh'. This will collect data for all CMF CBB. !!!"
}

#--------------------------------------
#Print an error and exit
#--------------------------------------
error()
{
   echo "$1"
   exit 1
}

#--------------------------------------
#Print debug information
#--------------------------------------
debug()
{
   if [ $COLLECT_DEBUG = "Y" ]
   then
       echo "$1"
   fi
}


#--------------------------------------
#get cpu id from command line and save it to cpuid.cfg
#--------------------------------------
get_cpuid()
{
    #Use iostat to get cpu usage for whole system
    echo "collectMan start to get data from : `date '+%m/%d/%y-%H:%M:%S'`" > ./report/temp_iostat_cpu.txt
    nohup iostat -c $COLLECT_PERIOD >> ./report/temp_iostat_cpu.txt &

    #Use mpstat to get cpu usage for each cpu
    echo "collectMan start to get data from : `date '+%m/%d/%y-%H:%M:%S'`" > ./report/temp_mpstat.txt
    nohup mpstat $COLLECT_PERIOD >> ./report/temp_mpstat.txt &

    if [ -f ./cpuid.cfg ]
    then
        rm ./cpuid.cfg
    fi
   
    while [ -n "$1" ]; do
    case $1 in
       -*) break;; # no more cpuid input
       *) echo $1 >> ./cpuid.cfg; shift 1;;
    esac
    done
}

#--------------------------------------
#Collect memory information
#--------------------------------------
get_memory()
{
    echo "collectMan start to get data from : `date '+%m/%d/%y-%H:%M:%S'`" > ./report/temp_vmstat.txt
    nohup vmstat $COLLECT_PERIOD >> ./report/temp_vmstat.txt &
}

#--------------------------------------
#get disk id from command line and save it to disk.cfg
#--------------------------------------
get_disk()
{
    #use iostat get disk io information
    echo "collectMan start to get data from : `date '+%m/%d/%y-%H:%M:%S'`" > ./report/temp_iostat.txt
    nohup iostat -xpn $COLLECT_PERIOD >> ./report/temp_iostat.txt &

    if [ -f ./disk.cfg ]
    then
        rm ./disk.cfg
    fi
   
    while [ -n "$1" ]; do
    case $1 in
       -*) break;; # no more disk input
       *) echo $1 >> ./disk.cfg; shift 1;;
    esac
    done

    #If not input parameter, get all disk partition in df -k list (but summary report just use first three partition)
    if [ ! -f ./disk.cfg ]
    then
    df -k |grep dsk |awk '{print $1}' > ./temp_disk.cfg
    while read LINE
    do
        basename  $LINE >> ./disk.cfg
        
        done < ./temp_disk.cfg
        rm ./temp_disk.cfg
    fi

    return 0
}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表