SharePlex 基於Solaris 10 Linux自動巡檢指令碼
1.check指令碼,可單獨執行,也可透過start指令碼呼叫
#!/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指令碼,不可單獨執行,需要呼叫上面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` # 統計sp_cop數量 if [ ${v_num_cop} -le 0 ];then # 判斷是否存在sp_cop程式,如果不存在,提示並退出執行 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取路徑,確保下面建立檔案在指令碼所在路徑 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 & # 呼叫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)會在指令碼所在目錄建立splex_check_log目錄 (2)用於存放生成的SharePlex_Report_開頭的log檔案,記錄SharePlex例項情況 (3)預設間隔20分鐘執行一次,可透過修改指令碼interval引數更改執行頻率 (4)會自動刪除三天前或者當日志目錄超過50M會自動刪除目錄重建 (5)該指令碼自動呼叫目錄下check_shareplex_health.sh指令碼 (6)指令碼執行步驟如下 chmod u+x start_check.sh chmod u+x stop_check.sh chmod u+x check_shareplex_health.sh ./start_check.sh & 2.停止指令碼使用如下指令碼 指令碼作用: (1)找出執行指令碼程式並執行kill命令 ./stop_check.sh 3.check_shareplex_health.sh指令碼說明 (1)該指令碼為start_check.sh指令碼最終呼叫巡檢指令碼 (2)郵箱傳送告警功能預設為註釋狀態,如果告警傳送郵件,則可以編輯check_shareplex_health.sh指令碼 a.配置伺服器sendmail功能,確保伺服器可以傳送郵件 b.去掉check_shareplex_health.sh開頭郵件部分註釋 c.修改MailUserName變數為需要傳送郵件地址,並將48行管道符前面註釋#去掉,就可以使用郵件功能
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31439444/viewspace-2672631/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 使用Linux expect批次巡檢Linux Aix Solaris磁碟使用率指令碼LinuxAI指令碼
- Linux基礎服務巡檢指令碼模板Linux指令碼
- dba巡檢指令碼指令碼
- mysql巡檢指令碼MySql指令碼
- SQL SERVER巡檢指令碼SQLServer指令碼
- shell指令碼企業巡檢指令碼
- [自動化]基於kolla部署的openstack自動化巡檢生成xlsx報告
- mysql 伺服器巡檢指令碼MySql伺服器指令碼
- Oracle運維指令碼-巡檢(RAC版)Oracle運維指令碼
- shell指令碼實現多臺伺服器自動巡檢--可參考學習指令碼伺服器
- Oracle運維指令碼-巡檢(單機版)Oracle運維指令碼
- 【SCRIPT】Oracle日常巡檢指令碼通用版Oracle指令碼
- 【開源】自動化巡檢系統,基於 Testng + Playwright + SpringBoot + Vue + Ant-DesignSpring BootVue
- 基於信創運維平臺,實現國產化網路自動巡檢運維
- Linux 新增指令碼開機自啟動Linux指令碼
- 基於DotNetty實現自動釋出 - 自動檢測程式碼變化Netty
- Oracle運維指令碼-巡檢(RAC版本)-V1.1Oracle運維指令碼
- 【SCRIPT】Oracle12C日常巡檢指令碼通用版Oracle指令碼
- 透過 Prometheus 編寫 TiDB 巡檢指令碼(指令碼已開源,內附連結)PrometheusTiDB指令碼
- 行業分析| 影片監控——AI自動巡檢行業AI
- Linux系統檢查指令碼Linux指令碼
- 業務場景自動化分享 (巡檢用例)
- 基於 Appium 的淘寶 618 列車喵幣自動領取指令碼APP指令碼
- Linux(CentOS)啟動時自動執行指令碼(rc.local)LinuxCentOS指令碼
- 基於PHP的Webshell自動檢測芻議PHPWebshell
- specjvm自動化指令碼JVM指令碼
- 自動備份指令碼指令碼
- 「乾貨」介面自動化實踐:高效智慧介面場景自動巡檢方案
- Linux基礎五(shell指令碼)Linux指令碼
- linux設定開機自啟動指令碼的最佳方式Linux指令碼
- linux透過shell指令碼實現ssh互動式自動化Linux指令碼
- SCRIPT】Oracle巡檢報告html格式樣例指令碼,帶趨勢圖OracleHTML指令碼
- Oracle 資料庫巡檢指令碼 單例項 RAC 輸出HTML格式Oracle資料庫指令碼單例HTML
- Ubuntu自動啟動配置指令碼Ubuntu指令碼
- Python——自動簽到指令碼Python指令碼
- Dockerfile---指令碼自動化Docker指令碼
- vue自動化部署指令碼Vue指令碼
- Solaris10怎麼更改子網掩碼?Solaris10更改子網掩碼的方法