Zabbix Monitoring of Oracle connections

Source: Internet
Author: User
Tags db connect python script

Monitoring the number of Oracle connections

Use Python scripting to monitor the number of Oracle connections, connect Oracle to install the Cx_oracle module, check for normal after installation is complete, no information returned as normal;

python -c "import cx_Oracle"

Typically, you also need to load the Oralce client configuration environment and libraries

libclntsh.so.11.1libnnz11.so
1. Write a Python script to check the current number of Oracle connections and the maximum number of connections: zabbix_check_process.py
#!/usr/bin/python# coding:utf-8## Check Oracle process# dbsession:current connect session# dbprocess:db Max Connect sess ion# presession:current Connect session precentimport Cx_oracleimport sys# conn to dbconn = Cx_oracle.connect (' User/[emai  L protected] ') cursor = conn.cursor () dbprocess = {}# current connect Sessionsessionsql = "SELECT COUNT (*) process from V$session "Cursor.execute (sessionsql) Sessionrow = Cursor.fetchone () dbprocess[' dbsession '] = sessionRow[0]# db max Connect Sessionprocesssql = "Select value count from v$parameter where name = ' Processes '" Cursor.execute (processsql) proce ow = Cursor.fetchone () dbprocess[' dbprocess '] = proce***ow[0]# Current Connect session precentpresession = float ( Sessionrow[0])/float (proce***ow[0]) dbprocess[' presession '] = '%.2f '% (presession * +) Cursor.close () # Close Dbconn.close () #print (DBPROCESS) try:if sys.argv[1]: if sys.argv[1] = = ' Dbsession ': print (dbprocess[' d  Bsession ']) if sys.argv[1] = = ' DBPROCESS ':          Print (dbprocess[' dbprocess ')) if sys.argv[1] = = ' Presession ': print (dbprocess[' presession ']) ex Cept:print ("Usage:%s dbsession |dbprocess |presession"% sys.argv[0])

Validation scripts

[[email protected] script]$ python zabbix_check_process.pyUsage: zabbix_check_process.py dbsession |dbprocess |presession[[email protected] script]$ python zabbix_check_process.py dbsession597[[email protected] script]$ python zabbix_check_process.py dbprocess1000[[email protected] script]$ python zabbix_check_process.py presession59.40
2, increase the userparamete:/opt/zabbix/etc/zabbix_agentd.conf.d/oracle.conf on the ZABBIX_AGENTD
## db connect sessionUserParameter=oracle.dbsession,source ~/.bash_profile;/usr/bin/python /opt/zabbix/share/script/zabbix_check_process.py dbsessionUserParameter=oracle.dbprocess,source ~/.bash_profile;/usr/bin/python /opt/zabbix/share/script/zabbix_check_process.py dbprocessUserParameter=oracle.presession,source ~/.bash_profile;/usr/bin/python /opt/zabbix/share/script/zabbix_check_process.py presession
3. Testing on the server (client needs to restart)
[[email protected] ~]# zabbix_get -s 10.0.18.121 -p 10050 -k ‘oracle.dbsession‘581[[email protected] ~]# zabbix_get -s 10.0.18.121 -p 10050 -k ‘oracle.presession‘58.10[[email protected] ~]# zabbix_get -s 10.0.18.121 -p 10050 -k ‘oracle.dbprocess‘1000
4. Create a template and add a monitoring project
Oracel数据库当前连接数的百分比         oracle.presession    60s    30d    90d    Zabbix 客户端    Oracle连接数    已启用Oracel数据库最大连接数                 oracle.dbprocess    60s    30d    90d    Zabbix 客户端    Oracle连接数    已启用Oracle数据库当前连接数                 oracle.dbsession    60s    30d    90d    Zabbix 客户端    Oracle连接数    已启用

5.

6. Download Information

The uploaded data includes the monitoring template, the database connection number monitoring, the table space Auto-discovery rule (monitoring),

Zabbix Monitoring of Oracle connections

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.