AIX host monitoring script

Source: Internet
Author: User

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 <Hostname: $ HOSTNAME Server: $ HOSTIP022User: $ USER Time: $ (date + % y'-'% M'-' % d' % H': '% m':' % S) 023 024 system check REPORT025 ========================== 026 027! 028} 029 030 # define the directory where the log file is stored and the log file name. Set the current user directory to LOG_PATH031LOG_PATH =$ (echo $ HOME) 032LOG_FILE = $ LOG_PATH/log'date + % Y % m % d % H % M % S '033 034 # Back Up Historical Files 035cd $ LOG_PATH036test-f log2007 * 037if ["$? "-Eq 0]; then038mv $ LOG_PATH/log2007 * $ LOG_PATH/niyl/>/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 "********* * ******************************** Chec K CPU ************************************** * ** "> $ LOG_FILE060vmstat 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.