diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-14 19:20:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-14 19:20:36 +0000 |
commit | dd24e74edfbafc09eaeb2dde0fda7eb3e1e86d0b (patch) | |
tree | 1e52f4dac2622ab377c7649f218fb49003b4cbb9 /collectors/python.d.plugin/oracledb/oracledb.chart.py | |
parent | Releasing debian version 1.39.1-2. (diff) | |
download | netdata-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/oracledb.chart.py')
-rw-r--r-- | collectors/python.d.plugin/oracledb/oracledb.chart.py | 57 |
1 files changed, 36 insertions, 21 deletions
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), |