這篇文章主要介紹SharePlex如何基于Solaris 10 Linux實現(xiàn)自動巡檢腳本,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!
成都創(chuàng)新互聯(lián)公司從2013年開始,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目成都網(wǎng)站制作、成都做網(wǎng)站網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元平塘做網(wǎng)站,已為上家服務(wù),為平塘各地企業(yè)和個人服務(wù),聯(lián)系電話:135182197921.check腳本,可單獨(dú)執(zhí)行,也可通過start腳本調(diào)用
#!/bin/bash # Created by czh version v1.0 # This script was used to check SharePlex Instance health. # This Script was created on RHEL 7.6 Platform and SunsOS 10.5. ############################################################################################################################################ #MailUserName='yourname@yourcompany' #if [ "$MailUserName" = "yourname@yourcompany" ] # then # echo "Please modify the script so it has a valid email address" # exit 0 #fi ############################################################################################################################################ # Start Scripts v_cop=`ps -ef|grep sp_cop|grep -v grep|awk '{print $2}'` v_num_cop=`ps -ef|grep sp_cop|grep -v grep|awk '{print $2}'|wc -l` v_os=`uname -a|awk '{print $1}'` i=1 if [ ${v_os} = "SunOS" ];then while [ $i -le ${v_num_cop} ] do v_pid=`echo ${v_cop}|/usr/xpg4/bin/awk -v v_i="${i}" '{print $v_i}'` v_script_name=`echo $0` v_dirname=`dirname ${v_script_name}` SP_SYS_HOST_NAME=`pfiles ${v_pid}|grep sockname|sed -n '$p'|awk '{print $3}'` SP_PORT=`pfiles $v_pid|grep sockname|sed -n '$p'|awk '{print $5}'` SP_PRODIR=`ps -ef|grep sp_cop|grep -v grep|grep ${v_pid}|awk '{print $8}'|cut -d '.' -f1|sed 's/\/$//'` SP_SYS_VARDIR=`pfiles ${v_pid}|sed -n '$p'|sed -n 's/\/rim//p'|tr -d " "` export SP_SYS_VARDIR export SP_SYS_HOST_NAME ${SP_PRODIR}/bin/sp_ctrl > ${v_dirname}/splex_temp.log <<EOF show version full exit EOF v_sp_version=`cat ${v_dirname}/splex_temp.log|grep -i "Version"` v_err_count=`egrep -i '(^Stopping|Aborting|Idle|Stopped by user|error)' ${v_dirname}/splex_temp.log |wc -l` if [ ${v_err_count} -eq 0 ];then echo -e "\n*********************************************" echo -e "`date +%A' '%F' '%H:%M:%S`" echo -e " SharePlex All Process Was Running " echo -e "*********************************************" else echo -e "\n*********************************************" echo -e " !!! Warnings !!!" echo -e " SharePlex Process Has Problems,Please Check!" echo -e "SharePlex Warnings ${SP_SYS_HOST_NAME}:${SP_PORT} Has Problems." #|mail -s 'SharePlex Warnings!' ${MailUserName} echo -e " `date +%A' '%F' '%H:%M:%S` " echo -e "*********************************************" fi echo -e "\n****************************************************************************************" echo -e " SharePlex Instance ${SP_PORT} Bind IP Address Is : ${SP_SYS_HOST_NAME}:${SP_PORT}" echo -e " SharePlex Product Directory Is : ${SP_PRODIR}" echo -e " SharePlex Version Is : ${v_sp_version}" echo -e " SharePlex Instance Vardir Directory Is : ${SP_SYS_VARDIR}" echo -e " SharePlex Instance Cop Process Identifier Is : ${v_pid}" echo -e " `date +%A' '%F' '%H:%M:%S`" echo -e "****************************************************************************************\n" i=$(($i+1)) done rm -f ${v_dirname}/splex_temp.log echo -e "\n######################################################################################################################" echo -e "\nFinished check SharePlex instance!" echo -e "`date +%A' '%F' '%H:%M:%S`\n" echo -e "######################################################################################################################\n" elif [ ${v_os} = "Linux" ];then while [ $i -le ${v_num_cop} ] do v_pid=`echo ${v_cop}|awk -v v_i="${i}" '{print $v_i}'` v_script_name=`echo $0` v_dirname=`dirname ${v_script_name}` v_sp_ipaddr=`netstat -anp|grep tcp|grep ${v_pid}|awk '{print $4}'` SP_SYS_HOST_NAME=`echo ${v_sp_ipaddr%:*}` SP_PORT=`echo ${v_sp_ipaddr##*:}` SP_PRODIR=`ps -ef|grep sp_cop|grep -v grep|grep ${v_pid}|awk '{print $8}'|cut -d '.' -f1|sed 's/\/$//'` SP_SYS_VARDIR=`ls -l /proc/${v_pid}/cwd|awk '{print $11}'|sed -n 's/\/dump$//p'` export SP_SYS_VARDIR export SP_SYS_HOST_NAME ${SP_PRODIR}/bin/sp_ctrl > ${v_dirname}/splex_temp.log <<EOF show version full exit EOF v_sp_version=`cat ${v_dirname}/splex_temp.log|grep -i "Version"` v_err_count=`egrep -i '(^Stopping|Aborting|Idle|Stopped by user|error)' ${v_dirname}/splex_temp.log |wc -l` if [ ${v_err_count} -eq 0 ];then echo -e "\n*********************************************" echo -e "`date +%A' '%F' '%H:%M:%S`" echo -e " SharePlex All Process Was Running " echo -e "*********************************************" else echo -e "\n*********************************************" echo -e " !!! Warnings !!!" echo -e " SharePlex Process Has Problems,Please Check!" echo -e "SharePlex Warnings ${SP_SYS_HOST_NAME}:${SP_PORT} Has Problems." echo -e " `date +%A' '%F' '%H:%M:%S` " echo -e "*********************************************" fi echo -e "\n****************************************************************************************" echo -e " SharePlex Instance ${SP_PORT} Bind IP Address Is : ${SP_SYS_HOST_NAME}:${SP_PORT}" echo -e " SharePlex Product Directory Is : ${SP_PRODIR}" echo -e " SharePlex Version Is : ${v_sp_version}" echo -e " SharePlex Instance Vardir Directory Is : ${SP_SYS_VARDIR}" echo -e " SharePlex Instance Cop Process Identifier Is : ${v_pid}" echo -e " `date +%A' '%F' '%H:%M:%S`" echo -e "****************************************************************************************\n" i=$(($i+1)) done rm -f ${v_dirname}/splex_temp.log echo -e "\n######################################################################################################################" echo -e "\nFinished check SharePlex instance!" echo -e "`date +%A' '%F' '%H:%M:%S`\n" echo -e "######################################################################################################################\n" else echo "Caution : This Platform Are Not Support,Please Contact The Vendor." fi # End Scripts
2.Start腳本,不可單獨(dú)執(zhí)行,需要調(diào)用上面check腳本
#!/bin/bash # Created by czh version v1.0 # This script was used to check SharePlex Instance health. # This Script was created on RHEL 7.6 Platform. v_log_dir_name=splex_check_log v_num_cop=`ps -ef|grep sp_cop|grep -v grep|awk '{print $2}'|wc -l` # 統(tǒng)計sp_cop數(shù)量 if [ ${v_num_cop} -le 0 ];then # 判斷是否存在sp_cop進(jìn)程,如果不存在,提示并退出執(zhí)行 echo -e "\n**************************************************************" echo -e " !!!No SharePlex Instance,Please Check!!! " echo -e "Please Check SharePlex Instance,The Sp_cop Process Not Active!" echo -e "**************************************************************\n" else echo -e "\n######################################################################################################################" echo -e "\nStarting Check" echo -e "`date +%A' '%F' '%H:%M:%S`\n" echo -e "######################################################################################################################\n" while true do v_dirname=`dirname $0` # 通過特殊變量$0取腳本名稱,使用dirname取路徑,確保下面創(chuàng)建文件在腳本所在路徑 if [ -d "${v_dirname}/${v_log_dir_name}" ];then echo "Notice: splex_check_log directory already exist,will continue." else mkdir -p ${v_dirname}/${v_log_dir_name} fi interval=1200 log_name=shareplex_check v_date=`date +%A-%F-%H%M%S` ${v_dirname}/check_shareplex_health.sh >> ${v_dirname}/${v_log_dir_name}/${log_name}_${v_date}.log & # 調(diào)用check_shareplex_health.sh腳本完成檢查 v_dir_size=`du -sk "${v_dirname}/${v_log_dir_name}"/|awk '{print $1}'` echo ${v_file_size} if [ ${v_dir_size} -ge 51200 ];then rm -rf ${v_dirname}/${v_log_dir_name} fi sleep ${interval} done fi
3.Stop腳本
#!/bin/bash # Created by czh version v1.0 # This script was used to check SharePlex Instance health. # This Script was created on RHEL 7.6 Platform. kill -9 `ps -ef|grep check_shareplex_health.sh|grep -v grep|awk '{print $2}'` 2>/dev/null kill -9 `ps -ef|grep start_check.sh|grep -v grep|awk '{print $2}'` 2>/dev/null
4.Readme文件
1.開始檢測 腳本作用: (1)會在腳本所在目錄創(chuàng)建splex_check_log目錄 (2)用于存放生成的SharePlex_Report_開頭的log文件,記錄SharePlex實例情況 (3)默認(rèn)間隔20分鐘執(zhí)行一次,可通過修改腳本interval參數(shù)更改執(zhí)行頻率 (4)會自動刪除三天前或者當(dāng)日志目錄超過50M會自動刪除目錄重建 (5)該腳本自動調(diào)用目錄下check_shareplex_health.sh腳本 (6)腳本執(zhí)行步驟如下 chmod u+x start_check.sh chmod u+x stop_check.sh chmod u+x check_shareplex_health.sh ./start_check.sh & 2.停止腳本使用如下腳本 腳本作用: (1)找出執(zhí)行腳本進(jìn)程并執(zhí)行kill命令 ./stop_check.sh 3.check_shareplex_health.sh腳本說明 (1)該腳本為start_check.sh腳本最終調(diào)用巡檢腳本 (2)郵箱發(fā)送告警功能默認(rèn)為注釋狀態(tài),如果告警發(fā)送郵件,則可以編輯check_shareplex_health.sh腳本 a.配置服務(wù)器sendmail功能,確保服務(wù)器可以發(fā)送郵件 b.去掉check_shareplex_health.sh開頭郵件部分注釋 c.修改MailUserName變量為需要發(fā)送郵件地址,并將48行管道符前面注釋#去掉,就可以使用郵件功能
以上是“SharePlex如何基于Solaris 10 Linux實現(xiàn)自動巡檢腳本”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道!
網(wǎng)站題目:SharePlex如何基于Solaris10Linux實現(xiàn)自動巡檢腳本-創(chuàng)新互聯(lián)
標(biāo)題來源:http://www.rwnh.cn/article42/hcdec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、網(wǎng)站設(shè)計公司、ChatGPT、搜索引擎優(yōu)化、定制網(wǎng)站、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容