Openfaclon篇-Oracle监控

一、 环境准备

  • cx_Oracle 对应你的python版本,下载地址https://qa.debian.org/watch/sf.php/cx-oracle
  • oracle-oracle-instantclient-basic 对应你要监控的oracle版本
  • oracle-instantclient-devel 对应你要监控的oracle版本

二、 使用方法

self.username = 'xxx'
self.password = 'xxx'
self.address = '1.1.1.1'
self.database = 'xxx'

替换成你要监控的oracle的用户名、密码、IP地址、SID即可。

三、 监控指标

('check_active','GAUGE'),
('rcachehit','GAUGE'),
('dsksortratio','GAUGE'),
('activeusercount','GAUGE'),
('dbsize','GAUGE'),
('dbfilesize','GAUGE'),
('commits','GAUGE'),
('rollbacks','GAUGE'),
('deadlocks','GAUGE'),
('redowrites','GAUGE'),
('tblscans','GAUGE'),
('tblrowsscans','GAUGE'),
('indexffs','GAUGE'),
('hparsratio','GAUGE'),
('netroundtrips','GAUGE'),
('logonscurrent','GAUGE'),
('lastarclog','GAUGE'),
('lastapplarclog','GAUGE'),
('bufbusywaits','GAUGE'),
('logswcompletion','GAUGE'),
('logfilesync','GAUGE'),
('logprllwrite','GAUGE'),
('enqueue','GAUGE'),
('dbseqread','GAUGE'),
('dbscattread','GAUGE'),
('dbsnglwrite','GAUGE'),
('dbprllwrite','GAUGE'),
('directread','GAUGE'),
('directwrite','GAUGE'),
('latchfree','GAUGE'),
('query_lock','GAUGE'),
('query_redologs','GAUGE'),
('query_rollbacks','GAUGE'),
('query_sessions','GAUGE'),
('fra_use','GAUGE')
  • 其中tablespacestablespaces_tempasm等空间监控会在main()函数初始化的使用,通过 self.get_tablespaces_add_monitlist()self.get_tablespaces_temp_add_monitlist()self.get_asm_add_monitlist()等方法自动计算出监控指标并追加到monit_keys列表中
  • 然后通过post方法直接将结果提交到transfer机器上
method = "POST"
handler = urllib2.HTTPHandler()
opener = urllib2.build_opener(handler)
url = 'http://172.18.14.5:6060/api/push'
request = urllib2.Request(url, data=json.dumps(p) )
request.add_header("Content-Type",'application/json')
request.get_method = lambda: method
try:
        pass
        connection = opener.open(request)
except urllib2.HTTPError,e:
        connection = e

if connection.code == 200:
        print connection.read()
else:
        print '{"err":1,"msg":"%s"}' % connection

三、 地址

https://github.com/babywd/Openfaclon-Oralce

    原文作者:大Q的梦想
    原文地址: https://www.jianshu.com/p/8b61df030ac0
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞