From b26be28df9fd4db2106cc2a557966c9d2a7345d9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 16 Mar 2019 08:50:20 +0100 Subject: Adding upstream version 1.13.0. Signed-off-by: Daniel Baumann --- .../python.d.plugin/postgres/postgres.chart.py | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'collectors/python.d.plugin/postgres/postgres.chart.py') diff --git a/collectors/python.d.plugin/postgres/postgres.chart.py b/collectors/python.d.plugin/postgres/postgres.chart.py index e988eec36..48880bb08 100644 --- a/collectors/python.d.plugin/postgres/postgres.chart.py +++ b/collectors/python.d.plugin/postgres/postgres.chart.py @@ -792,7 +792,6 @@ 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 self.server_version = None @@ -812,18 +811,20 @@ class Service(SimpleService): self.conn.close() self.conn = None - try: - 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) + conf = self.configuration + params = { + 'host': conf.get('host'), + 'port': conf.get('port', DEFAULT_PORT), + 'database': conf.get('database'), + 'user': conf.get('user', DEFAULT_USER), + 'password': conf.get('password'), + 'connect_timeout': conf.get('connect_timeout', DEFAULT_CONNECT_TIMEOUT), + 'options': '-c statement_timeout={0}'.format( + conf.get('statement_timeout', DEFAULT_STATEMENT_TIMEOUT)), + } + + try: self.conn = psycopg2.connect(**params) self.conn.set_isolation_level(extensions.ISOLATION_LEVEL_AUTOCOMMIT) self.conn.set_session(readonly=True) -- cgit v1.2.3