Linux 系統健康巡檢指令碼
客戶應用系統伺服器要做健康檢查,作業系統為Red Hat Enterprise Linux 5.6,資料庫為oracle 10g,寫了如下shell指令碼:
- #!/bin/bash
- echo "You are logged in as `whoami`";
- if [ `whoami` != root ]; then
- echo "Must be logged on as root to run this script."
- exit
- fi
- CHECK_DATE=`date +%F`
- echo "Running script. at `date`"
- CHECK_REPORT_PATH=/tmp/getinfo
- ls -d $CHECK_REPORT_PATH
- if [ $? -gt 0 ]
- then
- mkdir $CHECK_REPORT_PATH
- fi
- chmod -R 777 $CHECK_REPORT_PATH
- CURRENT_DIR=`pwd`
- echo "#################### Check Start ####################"
- HOST=`hostname`
- echo "********Hostname Check**********" >$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo "Hostname is $HOSTNAME" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #系統版本檢查
- echo "********OS Level**********" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- uname -a >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #系統日誌檢查
- echo "********System log*******" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- cat /var/log/messages >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #檔案系統檢查
- echo "********File System**********" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- df -h >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo "over 75%" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- df -h |grep '[7-9][5-9]%'>>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #網路地址配置資訊
- echo "********System /etc/hosts********" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- cat /etc/hosts >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #檢視記憶體使用情況
- echo "**********mem check************" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- free >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- vmstat >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #檢視磁碟讀寫情況
- echo "********io check**********" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- iostat >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #網路檢查
- echo "********network route check**********" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- netstat -rn >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo "********network check**********" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- ifconfig -a >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #環境變數檢查
- echo "********env info****************" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- env >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #使用者組檢查
- echo "********group info****************" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- cat /etc/group >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #使用者密碼檢查
- echo "********user info****************" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- cat /etc/passwd >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #檢查作業系統kernel資訊
- echo "********System kernel info****************" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- su - root -c $CURRENT_DIR/check_kernel.sh >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #檢查作業系統定時任務
- echo "********System crontab info****************" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- crontab -l >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #檢查系統裸裝置屬主
- echo "******** RAW****************" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- ls -l /dev/sd* >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- #檢查伺服器上執行的資料庫資訊
- echo "********get oracle info****************" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- Instance=`ps -ef|grep -v grep|grep oracle|awk '{print $1}'`
- for i in ${Instance}
- do
- su - $i -c $CHECK_REPORT_PATH/getdbinfo.sh
- done
- echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
- echo "#################### Check End! ####################"
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29067253/viewspace-2131572/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 系統巡檢指令碼指令碼
- mysql巡檢指令碼MySql指令碼
- dba巡檢指令碼指令碼
- sqlserver 巡檢指令碼SQLServer指令碼
- SQLServer巡檢指令碼SQLServer指令碼
- AIX巡檢指令碼(轉)AI指令碼
- (轉)ORACLE 巡檢指令碼Oracle指令碼
- SQL SERVER巡檢指令碼SQLServer指令碼
- Linux系統檢查指令碼Linux指令碼
- Linux基礎服務巡檢指令碼模板Linux指令碼
- shell指令碼企業巡檢指令碼
- 巡檢指令碼OS+Oracle指令碼Oracle
- Linux系統巡檢命令大盤點Linux
- oracle健康巡檢筆記Oracle筆記
- mysql 伺服器巡檢指令碼MySql伺服器指令碼
- db2巡檢小指令碼DB2指令碼
- oracle 巡檢指令碼(自動化)Oracle指令碼
- oracle、filesystem、backup日常巡檢指令碼Oracle指令碼
- Linux系統巡檢常用命令Linux
- Oracle運維指令碼-巡檢(RAC版)Oracle運維指令碼
- Oracle 10G RAC巡檢指令碼Oracle 10g指令碼
- (轉):oracle、filesystem、backup日常巡檢指令碼Oracle指令碼
- SharePlex 基於Solaris 10 Linux自動巡檢指令碼Linux指令碼
- MySQL資料庫健康檢查--MySQL巡檢MySql資料庫
- 轉:AIX 系統巡檢指令碼_超好用,不用一條條輸入命令了AI指令碼
- 使用Linux expect批次巡檢Linux Aix Solaris磁碟使用率指令碼LinuxAI指令碼
- Oracle運維指令碼-巡檢(單機版)Oracle運維指令碼
- 【SCRIPT】Oracle日常巡檢指令碼通用版Oracle指令碼
- 快速檢視LINUX 系統硬體的指令碼Linux指令碼
- MSSQL資料庫健康檢查--SQL Server巡檢SQL資料庫Server
- ORACLE提供檢驗RAC是否健康指令碼Oracle指令碼
- 使用oracheck進行系統巡檢
- 巡檢昨天到現在asm 、系統、資料庫等錯誤日誌 shell指令碼ASM資料庫指令碼
- Oracle運維指令碼-巡檢(RAC版本)-V1.1Oracle運維指令碼
- oracle 資料庫效能健康檢查指令碼Oracle資料庫指令碼
- 透過 Prometheus 編寫 TiDB 巡檢指令碼(指令碼已開源,內附連結)PrometheusTiDB指令碼
- 【SCRIPT】Oracle12C日常巡檢指令碼通用版Oracle指令碼
- python編寫的簡單的mysql巡檢指令碼PythonMySql指令碼