oracledb: make conn protocol configurable (#15104)
Ilya Mashchenko committed
May 29, 2023 at 13:00 UTC
1aed6efd3c603cf247dc56688d3543b6b650b490
2 files changed
+10
-3
collectors/python.d.plugin/oracledb/oracledb.chart.py
+6
-3
@@ -16,6 +16,7 @@ except ImportError:
16
HAS_ORACLE_NEW = False
17
try:
18
import cx_Oracle
19
+
20
HAS_ORACLE_OLD = True
21
except ImportError:
22
HAS_ORACLE_OLD = False
@@ -328,6 +329,7 @@ class Service(SimpleService):
329
self.password = configuration.get('password')
330
self.server = configuration.get('server')
331
self.service = configuration.get('service')
332
+ self.protocol = configuration.get('protocol', 'tcps')
333
self.alive = False
334
self.conn = None
335
self.active_tablespaces = set()
@@ -338,7 +340,8 @@ class Service(SimpleService):
340
self.conn = None
341
if HAS_ORACLE_NEW:
342
try:
341
- self.conn = cx_Oracle.connect(f'{self.user}/{self.password}@tcps://{self.server}/{self.service}')
343
+ self.conn = cx_Oracle.connect(
344
+ f'{self.user}/{self.password}@{self.protocol}://{self.server}/{self.service}')
345
except cx_Oracle.DatabaseError as error:
346
self.error(error)
347
return False
@@ -824,7 +827,7 @@ class Service(SimpleService):
827
'absolute',
828
1,
829
1000,
827
- ])
830
+ ])
831
self.charts['allocated_usage'].add_dimension(
832
[
833
'{0}_allocated_used'.format(name),
@@ -832,7 +835,7 @@ class Service(SimpleService):
835
'absolute',
836
1,
837
1000,
835
- ])
838
+ ])
839
self.charts['allocated_usage_in_percent'].add_dimension(
840
[
841
'{0}_allocated_used_in_percent'.format(name),
collectors/python.d.plugin/oracledb/oracledb.conf
+4
@@ -66,6 +66,8 @@
66
# server: localhost:1521 # the IP address or hostname (and port) of the Oracle Database Server. Required.
67
# service: XE # the Oracle Database service name. Required. To view the services available on your server,
68
# run this query: `select SERVICE_NAME from gv$session where sid in (select sid from V$MYSTAT)`.
69
+# protocol: tcp/tcps # one of the strings "tcp" or "tcps" indicating whether to use unencrypted network traffic
70
+# or encrypted network traffic
71
#
72
# ----------------------------------------------------------------------
73
# AUTO-DETECTION JOBS
@@ -76,9 +78,11 @@
78
# password: 'secret'
79
# server: 'localhost:1521'
80
# service: 'XE'
81
+# protocol: 'tcps'
82
83
#remote:
84
# user: 'netdata'
85
# password: 'secret'
86
# server: '10.0.0.1:1521'
87
# service: 'XE'
88
+# protocol: 'tcps'