Oracle12c RAC检测脚本

背景:oracle12c rac偶尔会有奇奇怪怪的问题,自己对这套集群架构也不是特别懂,主要在devops优维平台的自定义采集那里做了三个脚本做检测(ASM磁盘容量检测、集群心跳检测、集群状态检测):

1、ASM占用检测:

#!/usr/bin/python
# _*_coding: utf-8_*_
import cx_Oracle
import socket
import subprocess
import json
import platform
def oraclesql(cursor):
    #这里我们使用python的open方法打开文件并读取文件内容作为SQL语句执行
    #可使用绝对路径或相对路径
    fp=open('/home/oracle/scripts/asm_check.sql','r')
    fp1=fp.read()
    cursor.execute(fp1)
    data=cursor.fetchall()
    return data

if __name__=="__main__":
    oracle_data = {
        "ipaddress": ipaddress,
        "username": username,
        "password": password, 
        "port": port,
        "tnsname": tnsname
    }
    info_list4=[]
    #这里我们利用Python的异常处理来捕获异常,具体用法请参考文章开始提到的教程
    try:
        db = cx_Oracle.connect(oracle_data['username']+'/'+oracle_data['password']+'@'+oracle_data['ipaddress']+':'+oracle_data['port']+'/'+oracle_data['tnsname'])        
    except Exception as e:
        content= (oracle_data['tnsname']+' is Unreachable,The reason is '+ str(e)).strip()
        print (content)
  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值