From c60738977e42af061ef9ff7f4f275c4a72deb2ae Mon Sep 17 00:00:00 2001
From: Christopher Baines
Date: Sat, 16 Jan 2016 16:34:16 +0000
Subject: Add information about the licence to the web interface
---
prometheus_pgbouncer_exporter/cli.py | 19 ++++++++---
prometheus_pgbouncer_exporter/exposition.py | 49 +++++++++++++++++++++++++----
2 files changed, 58 insertions(+), 10 deletions(-)
diff --git a/prometheus_pgbouncer_exporter/cli.py b/prometheus_pgbouncer_exporter/cli.py
index 7284baa..f0807ce 100644
--- a/prometheus_pgbouncer_exporter/cli.py
+++ b/prometheus_pgbouncer_exporter/cli.py
@@ -16,13 +16,14 @@
# along with this program. If not, see .
import logging
-from http.server import HTTPServer
-
import configargparse
+
+from os.path import join, dirname, normpath
+from http.server import HTTPServer
from prometheus_client.core import REGISTRY
from .utils import get_connection
-from .exposition import RequestHandler
+from .exposition import create_request_handler
from .collectors import StatsCollector, ListsCollector, PoolsCollector, \
DatabasesCollector
@@ -61,6 +62,13 @@ def main():
env_var='PGBOUNCER_DATABASES',
)
+ p.add(
+ '--licence-location',
+ default=join(dirname(dirname(normpath(__file__))), 'LICENSE'),
+ help="The location of the licence, linked to through the web interface",
+ env_var='LICENCE_LOCATION',
+ )
+
options = p.parse_args()
logging.basicConfig(level=logging.DEBUG)
@@ -91,7 +99,10 @@ def main():
host = '0.0.0.0'
port = 9127
- httpd = HTTPServer((host, port), RequestHandler)
+ httpd = HTTPServer(
+ (host, port),
+ create_request_handler(options.licence_location),
+ )
logging.info("Listing on port %s:%d" % (host, port))
diff --git a/prometheus_pgbouncer_exporter/exposition.py b/prometheus_pgbouncer_exporter/exposition.py
index 4396b73..6f9123a 100644
--- a/prometheus_pgbouncer_exporter/exposition.py
+++ b/prometheus_pgbouncer_exporter/exposition.py
@@ -41,16 +41,53 @@ index_page = """
View metrics
+
+ Information
+
+ Copyright (C) 2015 Christopher Baines
+ View Licence
+
+
+
+ The source may be obtained from
+
+ this Git repository
+
+
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+