AIX host monitoring script
Last Update:2014-05-15
Source: Internet
Author: User
The AIX host monitoring script monitors the CPU, MEMROY, IO, NET, HACMP, and ERRORREPORT of the host. Monitors the tablespace, JOB, and ALERTLOG of the database. 001 #! /Bin/sh002003 # First load the configuration file. if the configuration file does not exist, return an error and exit 004... the AIX host monitoring script monitors the CPU, MEMROY, IO, NET, HACMP, and error report of the host. Monitors tablespaces, jobs, and ALERT logs of databases. 001 #! /Bin/sh002 003 # load the configuration file first. if the configuration file does not exist, exit 004 SOURCE = $ HOME/config/config005check_source () 006 {007if [-r $ SOURCE]. then008. $ SOURCE009else010echo "$ (basename $0): Cannot locate the default setting file. "011 exit 1012fi013} 014 015 # define the report header 016report_header () 017 {018 HOSTIP = $ (ifconfig-a | sed-n '2p' | awk '{print $2}') 019 HOSTNAME = $ (hostname) 020 USER = 'Who am I | cut-d ""-f1 '021cat /Dev/null 2> & 1039else040: 041fi042 043 # define temp directory, if not exist, create temp directory first1_44temp _ PATH = $ LOG_PATH/temp045if [-d $ TEMP_PATH]; then046: optional $ TEMP_PATH049fi050 051 #052check_source053 054 # output report header 055report_header> $ LOG_FILE056 057 058 # check CPU usage 059 echo "********* * ******************************* Check CPU ****** * ********************************** "> $ LOG_F ILE060vmstat 1 10 | awk '{print $0; if ($1 ~ /^ [0-9]. */) (totalcpu + = $16); (avecpu = 100-totalcpu/10)}; END {print "The average usage of cpu is: "avecpu} '> $ TEMP_PATH/cpu_info061 062cat $ TEMP_PATH/cpu_info> $ LOG_FILE063 placement = 'cat $ TEMP_PATH/cpu_info | grep" The average usage of cpu is "| awk-F ": "'{print $2}'' 065if ["$ cpu_used_pct"-gt "$ CPU_VALUE"]; then066echo "LOG-Warnning: 'date + % Y'-'% M'-' % d' % h': '% M':' % s', The CPU usage is Up to $ cpu_used_pct %. Please check the system. "> $ LOG_FILE067else068echo" The CPU load is OK !! ">>$ LOG_FILE069fi070 071 072 # memory usage monitoring, including monitoring of swap zone usage 073 echo >>$ LOG_FILE074echo >>$ LOG_FILE075echo "*********************** * **************** check memory useage ******************* * ******************** "> $ LOG_FILE076cat $ TEMP_PATH/cpu_info | awk '{print $0; if ($1 ~ /^ [0-9]. */) (totalpi + = $6) (totalpo + = $7)}; 077END {if (totalpi <10 & totalpo <10) print "The memory usage is OK !! "; If (totalpi> 10 | totalpo> 10) print" The memory pagein and pageout is to high, Please check the usage of the memory! "} '> $ LOG_FILE078 079 080 # check disk space. 081 echo> $ LOG_FILE082echo> $ LOG_FILE083echo "***************************** * *********** check disk space ************************* * *************** "> $ LOG_FILE084df-k> $ LOG_FILE085df-k | grep-v proc | grep-v Filesystem | awk '{x = 1 * $4} {print $1 ", "$2", "$3", "$4", "$5", "$6 ", "$7} '> $ TEMP_PATH/disk_info086 087cat $ TEMP_PATH/disk_info | grep-v' ^ # '| while read line088d O089item1 = $ (echo $ line | awk-F ', ''{print $1}') 090item2 = $ (echo $ line | awk-f ', ''{print $2} ') 091item3 = $ (echo $ line | awk-f','' {print $3 }') 092item4 = $ (echo $ line | awk-F ', ''{print $4}' | awk-f' %'' {print $1 }') 093item5 = $ (echo $ line | awk-F ', ''{print $5}') 094item6 = $ (echo $ line | awk-f ', ''{print $6} ') 095item7 = $ (echo $ line | awk-f','' {print $7 }') 096if ["$ item4"-gt "$ DISK_VALUE"]; Then097echo "LOG-Warnning: 'date + % Y'-'% M'-' % D'' % h': '% M':' % s ', $ item7 is not have enough space, please check. ">>$ LOG_FILE098else099echo" The space of disk $ item7 is OK !! ">>$ LOG_FILE100fi101done102 103 #104 # check disk I/O for monitoring, iostat105 #106 echo> $ log_file1_echo> $ log_file1_echo "*************************** * ************* check iostat ************************ * **************** "> $ log_file1_iostat 1 3> $ LOG_FILE110 111 # monitor network traffic by 112 echo> $ LOG_FILE113echo> $ LOG_FILE114echo "********************************** ******************************* ********* * "> $ LOG_FILE115netstat-I> $ LOG_FILE116 117 # Check the oracle background processes. 118 echo> $ LOG_FILE119echo> $ LOG_FILE120echo "***************************** * *********** check oracle process ************************* * *************** "> $ LOG_FILE121ps-ef | grep ora _ | grep-v grep | awk-F '-'' {print $2} '| awk' {print $2} '>/$ TEMP_PATH/ora_process_info122ps-ef | grep ora _ | grep-v grep >>$ LOG_FILE123 124 # background process ckpt125if ['grep ora_ckpt_ora92 $ TEMP_PATH/ora_process_info ']; then126COUNT = 1127else128echo "LOG-Warnning: 'date + % Y'-'% M'-' % d' % h': '% M':' % s', The Process ora_ckpt_ora92 was terminated! ">>$ LOG_FILE129fi130 131 # background process dbwr132if ['grep success $ TEMP_PATH/ora_process_info ']; then133COUNT = $ (COUNT + 1) 134else135echo" LOG-Warnning: 'date + % Y'-'% M'-' % d' % h': '% M':' % s', The Process ora_dbw0_ora92 was terminated! ">>$ LOG_FILE136fi137 138 # background process reco139if ['grep success $ TEMP_PATH/ora_process_info ']; then140COUNT = $ (COUNT + 1) 141else142echo" LOG-Warnning: 'date + % Y'-'% M'-' % d' % h': '% M':' % s', The Process ora_reco_ora92 was terminated! ">>$ LOG_FILE143fi144 145 # background process lgwr146if ['grep success $ TEMP_PATH/ora_process_info ']; then147COUNT = $ (COUNT + 1) 148else149echo" LOG-Warnning: 'date + % Y'-'% M'-' % d' % h': '% M':' % s', The Process ora_lgwr_ora92 was terminated! ">>$ LOG_FILE150fi151 152 # background process pmon153if ['grep success $ TEMP_PATH/ora_process_info ']; then154COUNT = $ (COUNT + 1) 155else156echo" LOG-Warnning: 'date + % Y'-'% M'-' % d' % h': '% M':' % s', The Process ora_pmon_ora92 was terminated! ">>$ LOG_FILE157fi158 159 # background process smon160if ['grep success $ TEMP_PATH/ora_process_info ']; then161COUNT = $ (COUNT + 1) 162else163echo" LOG-Warnning: 'date + % Y'-'% M'-' % d' % h': '% M':' % s', The Process ora_smon_ora92 was terminated! ">>$ LOG_FILE164fi165 166if [" $ COUNT "-eq 6]; then167echo >>$ LOG_FILE168echo" The main six Oracle processes is OK !! ">>$ LOG_FILE169else170: 171fi172 173 174 #175 # Check the oracle tablespace.176 #177 echo> $ LOG_FILE178echo> $ LOG_FILE179echo "****************** * ********************* check oracle tablespace ************** * ************************ "> $ LOG_FILE180 # su-oracle-c sqlplus dxh /dxh