summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/oracledb
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-14 19:20:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-14 19:20:36 +0000
commitdd24e74edfbafc09eaeb2dde0fda7eb3e1e86d0b (patch)
tree1e52f4dac2622ab377c7649f218fb49003b4cbb9 /collectors/python.d.plugin/oracledb
parentReleasing debian version 1.39.1-2. (diff)
downloadnetdata-dd24e74edfbafc09eaeb2dde0fda7eb3e1e86d0b.tar.xz
netdata-dd24e74edfbafc09eaeb2dde0fda7eb3e1e86d0b.zip
Merging upstream version 1.40.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/python.d.plugin/oracledb')
-rw-r--r--collectors/python.d.plugin/oracledb/README.md15
-rw-r--r--collectors/python.d.plugin/oracledb/oracledb.chart.py57
-rw-r--r--collectors/python.d.plugin/oracledb/oracledb.conf10
3 files changed, 48 insertions, 34 deletions
diff --git a/collectors/python.d.plugin/oracledb/README.md b/collectors/python.d.plugin/oracledb/README.md
index 722c77b75..315816de0 100644
--- a/collectors/python.d.plugin/oracledb/README.md
+++ b/collectors/python.d.plugin/oracledb/README.md
@@ -13,8 +13,7 @@ Monitors the performance and health metrics of the Oracle database.
## Requirements
-- `cx_Oracle` package.
-- Oracle Client (using `cx_Oracle` requires Oracle Client libraries to be installed).
+- `oracledb` package.
It produces following charts:
@@ -53,18 +52,13 @@ It produces following charts:
To use the Oracle module do the following:
-1. Install `cx_Oracle` package ([link](https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html)).
+1. Install `oracledb` package ([link](https://python-oracledb.readthedocs.io/en/latest/user_guide/installation.html)).
-2. Install Oracle Client libraries
- ([link](https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html#install-oracle-client)).
-
-3. Create a read-only `netdata` user with proper access to your Oracle Database Server.
+2. Create a read-only `netdata` user with proper access to your Oracle Database Server.
Connect to your Oracle database with an administrative user and execute:
-```
-ALTER SESSION SET "_ORACLE_SCRIPT"=true;
-
+```SQL
CREATE USER netdata IDENTIFIED BY <PASSWORD>;
GRANT CONNECT TO netdata;
@@ -88,6 +82,7 @@ local:
server: 'localhost:1521'
service: 'XE'
+
remote:
user: 'netdata'
password: 'secret'
diff --git a/collectors/python.d.plugin/oracledb/oracledb.chart.py b/collectors/python.d.plugin/oracledb/oracledb.chart.py
index 28ef8db10..455cf270e 100644
--- a/collectors/python.d.plugin/oracledb/oracledb.chart.py
+++ b/collectors/python.d.plugin/oracledb/oracledb.chart.py
@@ -8,11 +8,18 @@ from copy import deepcopy
from bases.FrameworkServices.SimpleService import SimpleService
try:
- import cx_Oracle
+ import oracledb as cx_Oracle
- HAS_ORACLE = True
+ HAS_ORACLE_NEW = True
+ HAS_ORACLE_OLD = False
except ImportError:
- HAS_ORACLE = False
+ HAS_ORACLE_NEW = False
+ try:
+ import cx_Oracle
+
+ HAS_ORACLE_OLD = True
+ except ImportError:
+ HAS_ORACLE_OLD = False
ORDER = [
'session_count',
@@ -187,7 +194,7 @@ CHARTS = {
},
}
-CX_CONNECT_STRING = "{0}/{1}@//{2}/{3}"
+CX_CONNECT_STRING_OLD = "{0}/{1}@//{2}/{3}"
QUERY_SYSTEM = '''
SELECT
@@ -322,6 +329,7 @@ class Service(SimpleService):
self.password = configuration.get('password')
self.server = configuration.get('server')
self.service = configuration.get('service')
+ self.protocol = configuration.get('protocol', 'tcps')
self.alive = False
self.conn = None
self.active_tablespaces = set()
@@ -330,18 +338,25 @@ class Service(SimpleService):
if self.conn:
self.conn.close()
self.conn = None
-
- try:
- self.conn = cx_Oracle.connect(
- CX_CONNECT_STRING.format(
- self.user,
- self.password,
- self.server,
- self.service,
- ))
- except cx_Oracle.DatabaseError as error:
- self.error(error)
- return False
+ if HAS_ORACLE_NEW:
+ try:
+ self.conn = cx_Oracle.connect(
+ f'{self.user}/{self.password}@{self.protocol}://{self.server}/{self.service}')
+ except cx_Oracle.DatabaseError as error:
+ self.error(error)
+ return False
+ else:
+ try:
+ self.conn = cx_Oracle.connect(
+ CX_CONNECT_STRING_OLD.format(
+ self.user,
+ self.password,
+ self.server,
+ self.service,
+ ))
+ except cx_Oracle.DatabaseError as error:
+ self.error(error)
+ return False
self.alive = True
return True
@@ -350,15 +365,15 @@ class Service(SimpleService):
return self.connect()
def check(self):
- if not HAS_ORACLE:
- self.error("'cx_Oracle' package is needed to use oracledb module")
+ if not HAS_ORACLE_NEW and not HAS_ORACLE_OLD:
+ self.error("'oracledb' package is needed to use oracledb module")
return False
if not all([
self.user,
self.password,
self.server,
- self.service,
+ self.service
]):
self.error("one of these parameters is not specified: user, password, server, service")
return False
@@ -812,7 +827,7 @@ class Service(SimpleService):
'absolute',
1,
1000,
- ])
+ ])
self.charts['allocated_usage'].add_dimension(
[
'{0}_allocated_used'.format(name),
@@ -820,7 +835,7 @@ class Service(SimpleService):
'absolute',
1,
1000,
- ])
+ ])
self.charts['allocated_usage_in_percent'].add_dimension(
[
'{0}_allocated_used_in_percent'.format(name),
diff --git a/collectors/python.d.plugin/oracledb/oracledb.conf b/collectors/python.d.plugin/oracledb/oracledb.conf
index 625717299..027215dad 100644
--- a/collectors/python.d.plugin/oracledb/oracledb.conf
+++ b/collectors/python.d.plugin/oracledb/oracledb.conf
@@ -63,9 +63,11 @@
#
# user: username # the username for the user account. Required.
# password: password # the password for the user account. Required.
-# server: localhost:1521 # the IP address or hostname of the Oracle Database Server. Required.
+# server: localhost:1521 # the IP address or hostname (and port) of the Oracle Database Server. Required.
# service: XE # the Oracle Database service name. Required. To view the services available on your server,
-# run this query: `SELECT value FROM v$parameter WHERE name='service_names'`.
+# run this query: `select SERVICE_NAME from gv$session where sid in (select sid from V$MYSTAT)`.
+# protocol: tcp/tcps # one of the strings "tcp" or "tcps" indicating whether to use unencrypted network traffic
+# or encrypted network traffic
#
# ----------------------------------------------------------------------
# AUTO-DETECTION JOBS
@@ -76,9 +78,11 @@
# password: 'secret'
# server: 'localhost:1521'
# service: 'XE'
+# protocol: 'tcps'
#remote:
# user: 'netdata'
# password: 'secret'
# server: '10.0.0.1:1521'
-# service: 'XE' \ No newline at end of file
+# service: 'XE'
+# protocol: 'tcps'