diff options
author | Pablo Carranza <pcarranza@gmail.com> | 2017-06-10 22:34:56 +0000 |
---|---|---|
committer | Pablo Carranza <pcarranza@gmail.com> | 2017-06-10 22:34:56 +0000 |
commit | eb9060e520d5711367253b80fa17e47614b2408c (patch) | |
tree | 876a96bbc73c3bdedce64fabafcf466889756d48 /prometheus_pgbouncer_exporter | |
parent | 7ea87dd5616e173fdf5dce2e030af051be79e2c9 (diff) | |
parent | 0a626be4cdc8eee651c008724559f338d47347c4 (diff) | |
download | prometheus-pgbouncer-exporter-eb9060e520d5711367253b80fa17e47614b2408c.tar prometheus-pgbouncer-exporter-eb9060e520d5711367253b80fa17e47614b2408c.tar.gz |
Merge branch 'pc-add-password' into 'master'
Add password as an argument
See merge request !1
Diffstat (limited to 'prometheus_pgbouncer_exporter')
-rw-r--r-- | prometheus_pgbouncer_exporter/__init__.py | 2 | ||||
-rw-r--r-- | prometheus_pgbouncer_exporter/cli.py | 13 | ||||
-rw-r--r-- | prometheus_pgbouncer_exporter/utils.py | 9 |
3 files changed, 15 insertions, 9 deletions
diff --git a/prometheus_pgbouncer_exporter/__init__.py b/prometheus_pgbouncer_exporter/__init__.py index 45b81bf..923225e 100644 --- a/prometheus_pgbouncer_exporter/__init__.py +++ b/prometheus_pgbouncer_exporter/__init__.py @@ -1,3 +1,3 @@ __ver_major__ = 1 -__ver_minor__ = 7 +__ver_minor__ = 8 __version__ = "%d.%d" % (__ver_major__, __ver_minor__) diff --git a/prometheus_pgbouncer_exporter/cli.py b/prometheus_pgbouncer_exporter/cli.py index 4f55f1e..91bbd0a 100644 --- a/prometheus_pgbouncer_exporter/cli.py +++ b/prometheus_pgbouncer_exporter/cli.py @@ -75,6 +75,12 @@ def main(): env_var='PGBOUNCER_USER', ) p.add( + '--pgbouncer-password', + default=None, + help="Password to connect to pgbouncer with", + env_var='PGBOUNCER_PASSWORD', + ) + p.add( '--pgbouncer-host', default=None, help="Host on which to connect to pgbouncer", @@ -106,9 +112,10 @@ def main(): logging.info(p.format_values()) connection = get_connection( - options.pgbouncer_user, - options.pgbouncer_port, - options.pgbouncer_host, + user = options.pgbouncer_user, + port = options.pgbouncer_port, + host = options.pgbouncer_host, + password = options.pgbouncer_password, ) REGISTRY.register(StatsCollector( diff --git a/prometheus_pgbouncer_exporter/utils.py b/prometheus_pgbouncer_exporter/utils.py index 7f9aae0..ea69f46 100644 --- a/prometheus_pgbouncer_exporter/utils.py +++ b/prometheus_pgbouncer_exporter/utils.py @@ -14,12 +14,11 @@ import psycopg2 -def get_connection(user, port, host): +def get_connection(user=None, port=None, host=None, dbname='pgbouncer', password=None): + kwargs = { 'user': user, 'port': port, 'host': host, 'dbname': dbname, 'password': password } + kwargs = dict([(k, v) for k, v in kwargs.items() if v]) connection = psycopg2.connect( - database='pgbouncer', - user=user, - port=port, - host=host, + **kwargs ) # pgbouncer does not support transactions (as it does not make sense to), |