Solaris环境下性能采集脚本H


#--------------------------------------
#main program
#--------------------------------------
echo >> collectMan.log
echo "`date '+%m/%d/%y-%H:%M:%S'`" >> collectMan.log

#If not input parameter, use default setting collect system information
if [ $# -lt 1 ]
then
    echo "No parameter input from command line, use default setting." | tee -a collectMan.log
    echo "Default setting is collect BMS Dm, database, and server cpu, memory,net and disk information." | tee -a collectMan.log
    echo "Use CollectMan.sh -h to get more help." | tee -a collectMan.log

    sh ./collectMan.sh -q -period 10 -process $PROCESSNAME -cpu -memory -diskio $DISKNAME -net -summary

    exit 0 
fi

#Check parameter
while [ -n "$1" ]; do
    debug "Now first parameter is '$1'"
    case $1 in
       -h) help;exit 0;;                   # Call script help.
       -zip) shift 1;COLLECT_ZIPFILE=Y;export COLLECT_ZIPFILE;;   # If file is too big, will zip file.
       -notzip) shift 1;COLLECT_ZIPFILE=N;export COLLECT_ZIPFILE;; # Set not zip file
       -period) shift 1;COLLECT_PERIOD=$1;export COLLECT_PERIOD;shift 1;; # Set collect period
       -process) shift 1; add_process_monitor $*;COLLECT_SHOWLIST="Y";; # Add a backgroud process to monitor for each daemon
       -cpu) shift 1;COLLECT_CPU="Y"; get_cpuid $*;COLLECT_SHOWLIST="Y";;     #Collect server cpu information
       -net) shift 1;COLLECT_NET="Y"; get_netif $*;COLLECT_SHOWLIST="Y";;     #Collect server network information
       -diskio) shift 1;COLLECT_IO="Y"; get_disk $*;COLLECT_SHOWLIST="Y";;    #Collect server disk information
       -memory) shift 1;COLLECT_MEMORY="Y"; get_memory;COLLECT_SHOWLIST="Y";;  #Collect server memory information
       -summary) shift 1; add_server_monitor;COLLECT_SHOWLIST="Y";;      # Add a backgroud process to monitor for server performance information
       -list) shift 1; list_collect_process;;      # list all process start up by collectMan
       -kill) shift 1; kill_collect_process N;;      # kill all process start up by collectMan
       -br) shift 1; backup_report;;      # Backup collectMan report
       -dr) shift 1; rm -f ./report/*.txt;;      # delete collectMan report
       -lr) shift 1; ls -l ./report;;      # list collectMan report
       -vsr) shift 1; dtpad ./report/server_summary_report.txt;;    #view summary report
       -vpr) shift 1; dtpad ./report/PS_$1.txt;shift 1;;            #view process report
       -q) shift 1;quick_mode $*; exit 0;;                   # Call script help.
       -process_monitor) shift 1; process_monitor $1;; # get the process information and save to file
       -server_summary_report) shift 1; server_summary_report;; # get the server information and save to file
       --) shift;break;; # end of options
       -*) usage; error "error: no such option '$1'. Use -h to get help";;
       *) shift;;
    esac
done

#show collect process list after running collectMan.
if [ "$COLLECT_SHOWLIST" = "Y" ]
then
    echo "*************************************************************"
    echo "Start collectMan successfully."
    sh ./collectMan.sh -list
    echo "*************************************************************"
    echo "You can use 'sh ./collectMan.sh -kill' to kill all collectMan process."
   
    COLLECT_SHOWLIST="N"
fi

exit 0


猜你喜欢

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