Solaris环境下性能采集脚本F


COLLECT_PSS_MEMSIZE_CPU=""
for pp in $PROCESSES
do
    COLLECT_PSS_MEMSIZE_CPU="$COLLECT_PSS_MEMSIZE_CPU\t`tail -1 ./report/PS_$pp.txt|awk '{print $2}'`"
            COLLECT_PSS_MEMSIZE_CPU="$COLLECT_PSS_MEMSIZE_CPU\t`tail -1 ./report/PS_$pp.txt|awk '{print $4}'`"
        done
       
        COLLECT_DISKS=""
        for dd in $DISKS
        do
            COLLECT_DISKS="$COLLECT_DISKS\t`grep $dd ./report/temp_iostat.txt |tail -1|awk '{print $9}'`"
            COLLECT_DISKS="$COLLECT_DISKS\t`grep $dd ./report/temp_iostat.txt |tail -1|awk '{print $10}'`"
            COLLECT_DISKS="$COLLECT_DISKS\t`grep $dd ./report/temp_iostat.txt |tail -1|awk '{print $1}'`"
            COLLECT_DISKS="$COLLECT_DISKS\t`grep $dd ./report/temp_iostat.txt |tail -1|awk '{print $2}'`"
            COLLECT_DISKS="$COLLECT_DISKS\t`grep $dd ./report/temp_iostat.txt |tail -1|awk '{print $3}'`"
            COLLECT_DISKS="$COLLECT_DISKS\t`grep $dd ./report/temp_iostat.txt |tail -1|awk '{print $4}'`"
done

         #debug "$COLLECT_DISK1_W"
        #debug "$COLLECT_DISK3_B"
       
        COLLECT_NETIFS_IO=""
        for nn in $NETIFS
        do
            COLLECT_NETIFS_LINE="`tail -1 ./report/temp_netstat_$nn\.txt`"
            COLLECT_NETIFS_IO="$COLLECT_NETIFS_IO\t"`echo $COLLECT_NETIFS_LINE|awk '{print $1}'`
            COLLECT_NETIFS_IO="$COLLECT_NETIFS_IO\t"`echo $COLLECT_NETIFS_LINE|awk '{print $3}'`
        done
        #debug "$COLLECT_NETIF1_LINE"

        #for IPMS test
        #COLLECT_IPMS_MEM_SIZE=`tail -1 ./report/PS_IPMSDm.txt|awk '{print $2}'`
        #COLLECT_IPMS_MEM_RSS=`tail -1 ./report/PS_IPMSDm.txt|awk '{print $3}'`
        #COLLECT_IPMS_CPU=`tail -1 ./report/PS_IPMSDm.txt|awk '{print $4}'`
        #COLLECT_DB_CPU=`tail -1 ./report/PS_dataserver.txt|awk '{print $4}'`
       
        #summary report line
        SR_LINE="`date '+%m/%d/%y-%H:%M:%S'`"
        SR_LINE="$SR_LINE\t$COLLECT_CPU_SYS"
        SR_LINE="$SR_LINE\t$COLLECT_CPU_USR"
        SR_LINE="$SR_LINE\t$COLLECT_CPU_WAIT"
        SR_LINE="$SR_LINE\t$COLLECT_CPU_ID"
        SR_LINE="$SR_LINE\t$COLLECT_MEM_SWAP"
        SR_LINE="$SR_LINE\t$COLLECT_MEM_FREE"

        SR_LINE="$SR_LINE$COLLECT_PSS_MEMSIZE_CPU"

        SR_LINE="$SR_LINE$COLLECT_DISKS"
       
        SR_LINE="$SR_LINE$COLLECT_NETIFS_IO"

       
        echo "$SR_LINE" >> ./report/server_summary_report.txt
        #wait for next period
        sleep $COLLECT_PERIOD          
    done
}

#Rename file and compress file if file size is too larger
zipfile()
{
     if [ $# -ne 1 ]
     then
         echo "Parameter not accord the assert."
         exit 0 
     fi

     #if files is too large, gzip it and resverve it.
     FILELENGTH=`ls -l $1`
     FILELENGTH=`echo $FILELENGTH | awk '{print $5}'`
     if [ $FILELENGTH -ge $FILE_MAX_LENGTH ]
     then
       DATE=`date +%y%m%d%H`
       mv $1.txt $1.txt.$DATE 
       if [ $COLLECT_ZIPFILE = "Y" ]
       then
           gzip $1.txt.$DATE &        
       fi
     fi   
}

你可能感兴趣的:(脚本,F#,Solaris)