aboutsummaryrefslogtreecommitdiffstats
path: root/prometheus.py
diff options
context:
space:
mode:
authorgenofire <geno+dev@fireorbit.de>2019-12-07 16:01:03 +0100
committergenofire <geno+dev@fireorbit.de>2019-12-07 16:01:58 +0100
commita5a39958cc37f1415457d8361d7bcde5c1d34325 (patch)
treedb2ddc0590f9641230ad2a673c2d2da73db98701 /prometheus.py
parent39ae668307bebc2069c23ec8542b4271fde94a8e (diff)
improve configuration (with default values) - also for testing ejabberdrpc.py
Diffstat (limited to 'prometheus.py')
-rwxr-xr-xprometheus.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/prometheus.py b/prometheus.py
index e534f16..dfca7d4 100755
--- a/prometheus.py
+++ b/prometheus.py
@@ -86,9 +86,25 @@ class Prometheus():
t.start()
if __name__ == "__main__":
- metrics = EjabberdMetrics("http://[::1]:4560")
+ import os
+ import json
+
+ # load config
+ path = os.path.dirname(__file__)
+ with open("/".join([path, "config.json"]), "r", encoding="utf-8") as f:
+ config = json.load(f)
+
+
+ url = config['url'] if "url" in config else "http://[::1]:5280/api"
+ login = config['login'] if "login" in config else None
+ api = config['api'] if "api" in config else "rest"
+
+ prom_port = config['prometheus_port'] if "prometheus_port" in config else 8080
+ prom_refresh = config['prometheus_refresh'] if "prometheus_refresh" in config else 10
+
+ metrics = EjabberdMetrics(url, login, api)
prom = Prometheus(metrics)
- prom.listen(8080)
+ prom.listen(prom_port)
while True:
metrics.update()
- time.sleep(10)
+ time.sleep(prom_refresh)