虚拟化容器,大数据,DBA,中间件,监控。

Centos Oracle 10g 系统巡查脚本

19 10月
作者:admin|分类:DBA运维

  

Centos Oracle 10g 系统巡查脚本

比较简单,可以自行添加内容

以下是详细命令:


  #!/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.txt`
    echo "Running script. at `date`"
    CHECK_REPORT_PATH=/data
    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 ####################"


    #网络地址配置信息
    echo "********主机IP地址********" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE

    ifconfig|grep inet|grep -v 127.0.0.1|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p' >>$CHECK_REPORT_PATH/Report_$CHECK_DATE

   #centos7系统请使用以下命令ifconfig |sed -n '/inet /p'|awk '{print $2}'|grep -v 127.0.0.1

    route |grep default | awk '{print $2}' >>$CHECK_REPORT_PATH/Report_$CHECK_DATE

     echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE


   #文件系统检查
    echo "********硬盘使用情况**********" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
    df -h >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
    echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
   
   #查看内存使用情况

    echo "**********CPU内存使用情况************" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE

   cat /proc/cpuinfo|grep "name"|cut -d: -f2 |awk '{print "*"$1,$2,$3,$4}'|uniq -c >>$CHECK_REPORT_PATH/Report_$CHECK_DATE

    free -m >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
    echo -e "----------------------------------------------------\n">>$CHECK_REPORT_PATH/Report_$CHECK_DATE
       
    #检查服务器上运行的数据库信息
if grep oracle /etc/passwd
then
    echo "********Oracle 表空间分析****************" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
    su - oracle -c "sqlplus /nolog <<EOF
      connect /as sysdba
      set linesize 150
      column free_G format 9990.99
 column used_G format 9990.99
 column total_G format 9990.99
      column tablespace_name format a20
 column used_percent format a10
      select f.tablespace_name tablespace_name,round((d.sumbytes/1024/1024/1024),2) total_G,
      round(f.sumbytes/1024/1024/1024,2) free_G,
      round((d.sumbytes-f.sumbytes)/1024/1024/1024,2) used_G,
      round((d.sumbytes-f.sumbytes)*100/d.sumbytes,2)||'%' used_percent
      from (select tablespace_name,sum(bytes) sumbytes from dba_free_space group by tablespace_name) f,
      (select tablespace_name,sum(bytes) sumbytes from dba_data_files group by tablespace_name) d
      where f.tablespace_name= d.tablespace_name
      order by d.tablespace_name;
      col file_name for a60
      col TOTAL_GB for 999990.99
      col FREE_GB for 999990.99
      col FREE_PERC for 9990.99
      select a.file_name,
       round(a.bytes / 1024 / 1024, 0) as TOTAL_MB,
       round(nvl(b.sb,0) / 1024 / 1024, 0) as FREE_MB,
       round(100 * NVL(b.sb,0) / a.bytes, 2) as FREE_PERC
       from dba_data_files a,
       (select file_id, sum(BYTES) sb from dba_free_space group by file_id) b
       where (a.file_id = b.file_id(+) and a.file_name like '%%%') order by a.file_name;
    exit;
    EOF
    exit" >>$CHECK_REPORT_PATH/Report_$CHECK_DATE
   else 
     echo "本主机系统没有运行oracle数据库" >> $CHECK_REPORT_PATH/Report_$CHECK_DATE
   fi
echo "#################### Check End! ####################"
浏览1875 评论0
返回
目录
返回
首页
使用 ionice 限制 Xen 虚拟机磁盘 IO Zabbix通过Orabbix监控Oracle