0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-05-17 22:52:21 +00:00

postgres timeouts ()

* added `connect_timeout` and `statement_timeout` to postgres

* change default statement_timeout to 5
This commit is contained in:
Ilya Mashchenko 2018-12-14 23:34:44 +03:00 committed by GitHub
parent 39ad3c587d
commit 9a3e8f1708
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 10 deletions
collectors/python.d.plugin/postgres

View file

@ -17,6 +17,12 @@ except ImportError:
from bases.FrameworkServices.SimpleService import SimpleService
DEFAULT_PORT = 5432
DEFAULT_USER = 'postgres'
DEFAULT_CONNECT_TIMEOUT = 2 # seconds
DEFAULT_STATEMENT_TIMEOUT = 5000 # ms
WAL = 'WAL'
ARCHIVE = 'ARCHIVE'
BACKENDS = 'BACKENDS'
@ -787,6 +793,7 @@ class Service(SimpleService):
self.do_table_stats = configuration.pop('table_stats', False)
self.do_index_stats = configuration.pop('index_stats', False)
self.databases_to_poll = configuration.pop('database_poll', None)
self.statement_timeout = configuration.pop('statement_timeout', DEFAULT_STATEMENT_TIMEOUT)
self.configuration = configuration
self.conn = None
@ -811,11 +818,15 @@ class Service(SimpleService):
self.conn = None
try:
params = dict(user='postgres',
database=None,
password=None,
host=None,
port=5432)
params = dict(
host=None,
port=DEFAULT_PORT,
database=None,
user=DEFAULT_USER,
password=None,
connect_timeout=DEFAULT_CONNECT_TIMEOUT,
options='-c statement_timeout={0}'.format(self.statement_timeout),
)
params.update(self.configuration)
self.conn = psycopg2.connect(**params)