Skip to content
Scripts checks oracle database's parameters and send data to zabbix server.
Python
Branch: master
Clone or download

Latest commit

Latest commit 3100eae May 3, 2018

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cron.d Added main scripts Mar 23, 2017
externalscripts zabbix.api is deprecated, changed to pyzabbix Feb 21, 2018
zabbix_agentd.d Added main scripts Mar 23, 2017
zbx_templates Added zabbix template Mar 23, 2017
.gitattributes 🎉 Added .gitattributes & .gitignore files Mar 23, 2017
.gitignore 🎉 Added .gitattributes & .gitignore files Mar 23, 2017
README.md minor explanations May 3, 2018

README.md

Description

Oracle database monitoring through Zabbix.

Based on https://github.com/bicofino/Pyora

Scripts checks database's parameters and send data to zabbix server.

pyora-discovery.py performs discovery databases asm volumes, tablespaces and users.

pyora-items-list.py gets items list from zabbix server that will be checked and creates item list file.

pyora-active.py performs requests to oracle database and sends report to zabbix server.

pyora_config.py contains zabbix login and password to oracle database. Its included in scripts.

Dependencies

oracle instantclient

zabbix-agent

python

cx-Oracle

python-argparse

py-zabbix

Installation

  1. Create Oracle user for Pyora usage

CREATE USER ZABBIX IDENTIFIED BY 'REPLACE WITH PASSWORD' DEFAULT TABLESPACE SYSTEM TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK;
GRANT CONNECT TO ZABBIX;
GRANT RESOURCE TO ZABBIX;
ALTER USER ZABBIX DEFAULT ROLE ALL;
GRANT SELECT ANY TABLE TO ZABBIX;
GRANT CREATE SESSION TO ZABBIX;
GRANT SELECT ANY DICTIONARY TO ZABBIX;
GRANT UNLIMITED TABLESPACE TO ZABBIX;
GRANT SELECT ANY DICTIONARY TO ZABBIX;
GRANT SELECT ON V_$SESSION TO ZABBIX;
GRANT SELECT ON V_$SYSTEM_EVENT TO ZABBIX;
GRANT SELECT ON V_$EVENT_NAME TO ZABBIX;
GRANT SELECT ON V_$RECOVERY_FILE_DEST TO ZABBIX;
  1. Create zabbix api user in web-interface with read permissions on group, where databases hosts will be.

  2. Install on the host from which the checks will be performed:

    a. oracle instantclient

    b. https://pypi.python.org/pypi/cx_Oracle/5.2.1

    c. https://github.com/blacked/py-zabbix

    d. zabbix agent

  3. Copy externalscripts/* to /usr/lib/zabbix/externalscripts/

  4. Set scripts mode bits:


chmod 755 /usr/lib/zabbix/externalscripts/pyora-active.py /usr/lib/zabbix/externalscripts/pyora-discovery.py /usr/lib/zabbix/externalscripts/pyora-items-list.py
  1. Edit /usr/lib/zabbix/externalscripts/pyora_config.py

  2. Copy zabbix_agentd.d/oracle_pyora.conf to /etc/zabbix/zabbix_agentd.d/ and restart zabbix agent.

  3. Create directory which will be contains items list for every database.


mkdir /usr/lib/zabbix/cache
chown zabbix:zabbix /usr/lib/zabbix/cache
  1. Import to zabbix "Template Pyora active send".

  2. Create via zabbix web interface host, from which the checks will be performed.

Fill macros:

* {$ADDRESS} - address oracle database	
* {$DATABASE} - databases SID
* {$ZABBIXURL} - zabbix api URL, like "http://zabbix.net.local" (needed for pyora-items-list.py script)
* {$ZABBIXUSER} - zabbix api user
* {$ZABBIXPASSWORD} - zabbix api password
* {$ASMHIGH} - warn level for asm volume fill in percents
* {$HIGH} - warn level for tablespace fill in percents

Link "Template Pyora active send" to this host.

  1. Create cron job with databases parameters, like:

*/10 * * * * zabbix /usr/lib/zabbix/externalscripts/pyora-active.py  --address database_address --database database_SID
  1. Configure needed template and hosts items

Usage and tests


# Show the tablespaces names in a JSON format
pyora-discovery.py --address db_address --database db_SID show_tablespaces

# Create items list for database "SID" with address "10.0.0.1". Zabbix host "SID on db_host" and zabbix API user/password: DBmonitor/pass
pyora-items-list.py  --zabbixurl http://zabbix.net.local --zabbixuser "DBmonitor" --zabbixpassword "pass" --hostname "SID on db_host" --address "10.0.0.1" --database "SID"


# pyora-active.py -h
pyora-active.py [-h] --address ADDRESS --database DATABASE
                       [--username USERNAME] [--password PASSWORD]
                       [--port PORT] [--ora1000] [--verbose]

optional arguments:
  -h, --help           show this help message and exit
  --address ADDRESS    Oracle database address
  --database DATABASE  Oracle database SID
  --username USERNAME  Oracle database user
  --password PASSWORD  Oracle database user's password
  --port PORT          Oracle database port
  --ora1000            recconnect to Oracle database when request tablespace's
                       size (bug 17897511)
  --verbose, -v        Additional verbose information


# Perform checks by items list and print additional verbose information for every check
pyora-active.py  --address 10.0.0.1 --database SID  -v

Processing: uptime
                        883231
Data to send:
[{"host": "SID on db_host", "value": "883231", "key": "uptime"}]
{"failed": 0, "chunk": 1, "total": 1, "processed": 1, "time": "0.000050"}


Processing: version
                        Oracle Database 11g Release 11.2.0.4.0 - 64bit Production
Data to send:
[{"host": "SID on db_host", "value": "Oracle Database 11g Release 11.2.0.4.0 - 64bit Production", "key": "version"}]
{"failed": 0, "chunk": 1, "total": 1, "processed": 1, "time": "0.000045"}
You can’t perform that action at this time.