Solaris环境下性能采集脚本H

本文介绍了一个Shell脚本,用于监控系统的多个方面,包括CPU使用率、内存使用情况、网络状态、磁盘IO等,并提供了丰富的命令行参数来定制监控行为。通过此脚本,用户可以灵活地收集服务器的运行状况。
#--------------------------------------
#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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值