Solaris环境下性能采集脚本E
#--------------------------------------
#Loop to get server information and create summary report
#--------------------------------------
server_summary_report()
{
##get netif name
#netif1=`head -1 ./netif.cfg|tail -1`
#netif2=`head -2 ./netif.cfg|tail -1`
NETIFS=`tail -100 netif.cfg`
#while read LINE
#do
# NETIFS="$NETIFS$LINE"
#done < ./netif.cfg
##get disk name
#disk1=`head -1 ./disk.cfg|tail -1`
#disk2=`head -2 ./disk.cfg|tail -1`
#disk3=`head -3 ./disk.cfg|tail -1`
DISKS=`tail -100 disk.cfg`
#while read LINE
#do
#DISKS="$DISKS$LINE"
#done <./disk.cfg
##get process name
#PS1=`head -1 ./process.cfg|tail -1`
#PS2=`head -2 ./process.cfg|tail -1`
#PS3=`head -3 ./process.cfg|tail -1`
PROCESSES=`tail -100 process.cfg`
#while read LINE
#do
# PROCESSES="$PROCESSES$LINE"
#done < ./process.cfg
SR_HEAD="DATETIME"
SR_HEAD="$SR_HEAD\tCPU_US"
SR_HEAD="$SR_HEAD\tCPU_SY"
SR_HEAD="$SR_HEAD\tCPU_WT"
SR_HEAD="$SR_HEAD\tCPU_ID"
SR_HEAD="$SR_HEAD\tMEM_SWAP"
SR_HEAD="$SR_HEAD\tMEM_FREE"
for pp in $PROCESSES
do
SR_HEAD="$SR_HEAD\t$pp\MEMSIZE"
SR_HEAD="$SR_HEAD\t$pp\CPU"
done
for dd in $DISKS
do
echo $dd >> ./test.txt
SR_HEAD="$SR_HEAD\t$dd\%w"
SR_HEAD="$SR_HEAD\t$dd\%b"
SR_HEAD="$SR_HEAD\t$dd\ r/s"
SR_HEAD="$SR_HEAD\t$dd\w/s"
SR_HEAD="$SR_HEAD\t$dd\kr/s"
SR_HEAD="$SR_HEAD\t$dd\kw/s"
done
for nn in $NETIFS
do
SR_HEAD="$SR_HEAD\t$nn\outpackets"
SR_HEAD="$SR_HEAD\t$nn\inpackets"
done
#get data and save to summary report
while [ 1 ]
do
#Create file and input report head
if [ ! -f ./report/server_summary_report.txt ]
then
echo $SR_HEAD > ./report/server_summary_report.txt
fi
COLLECT_CPU_LINE=`tail -1 ./report/temp_iostat_cpu.txt`
COLLECT_CPU_SYS=`echo $COLLECT_CPU_LINE|awk '{print $1}'`
COLLECT_CPU_USR=`echo $COLLECT_CPU_LINE|awk '{print $2}'`
COLLECT_CPU_WAIT=`echo $COLLECT_CPU_LINE|awk '{print $3}'`
COLLECT_CPU_ID=`echo $COLLECT_CPU_LINE|awk '{print $4}'`
COLLECT_MEM_LINE="`tail -1 ./report/temp_vmstat.txt`"
COLLECT_MEM_SWAP="`echo $COLLECT_MEM_LINE|awk '{print $4}'`"
COLLECT_MEM_FREE="`echo $COLLECT_MEM_LINE|awk '{print $5}'`"
#debug "$COLLECT_MEM_LINE"
#debug $COLLECT_MEM_SWAP
#debug $COLLECT_MEM_FREE