aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2016-02-27 17:53:34 +0000
committerChristopher Baines <mail@cbaines.net>2016-02-27 17:53:34 +0000
commitf4585e65716404c8ee5ad22758b8967dad1966e7 (patch)
tree740b760a2c1d7372ee7ca630b4bd1377d71e30f5
parent01b0377f5b0cc6d44e45e9bd249d0d8c632279b3 (diff)
downloadprometheus-pgbouncer-exporter-f4585e65716404c8ee5ad22758b8967dad1966e7.tar
prometheus-pgbouncer-exporter-f4585e65716404c8ee5ad22758b8967dad1966e7.tar.gz
Support connecting to pgbouncer on a different host
-rw-r--r--prometheus_pgbouncer_exporter/cli.py12
-rw-r--r--prometheus_pgbouncer_exporter/utils.py3
2 files changed, 13 insertions, 2 deletions
diff --git a/prometheus_pgbouncer_exporter/cli.py b/prometheus_pgbouncer_exporter/cli.py
index 6e4b5a0..a0b023f 100644
--- a/prometheus_pgbouncer_exporter/cli.py
+++ b/prometheus_pgbouncer_exporter/cli.py
@@ -73,6 +73,12 @@ def main():
help="User to connect to pgbouncer with",
env_var='PGBOUNCER_USER',
)
+ p.add(
+ '--pgbouncer-host',
+ default=None,
+ help="Host on which to connect to pgbouncer",
+ env_var='PGBOUNCER_HOST',
+ )
p.add(
'--database',
@@ -98,7 +104,11 @@ def main():
logging.info(p.format_values())
- connection = get_connection(options.pgbouncer_user, options.pgbouncer_port)
+ connection = get_connection(
+ options.pgbouncer_user,
+ options.pgbouncer_port,
+ options.pgbouncer_host,
+ )
REGISTRY.register(StatsCollector(
connection=connection,
diff --git a/prometheus_pgbouncer_exporter/utils.py b/prometheus_pgbouncer_exporter/utils.py
index 12e9ddd..7f9aae0 100644
--- a/prometheus_pgbouncer_exporter/utils.py
+++ b/prometheus_pgbouncer_exporter/utils.py
@@ -14,11 +14,12 @@
import psycopg2
-def get_connection(user, port):
+def get_connection(user, port, host):
connection = psycopg2.connect(
database='pgbouncer',
user=user,
port=port,
+ host=host,
)
# pgbouncer does not support transactions (as it does not make sense to),