aboutsummaryrefslogtreecommitdiffstats
path: root/influx.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 /influx.py
parent39ae668307bebc2069c23ec8542b4271fde94a8e (diff)
improve configuration (with default values) - also for testing ejabberdrpc.py
Diffstat (limited to 'influx.py')
-rw-r--r--influx.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/influx.py b/influx.py
index 049bef0..b267e23 100644
--- a/influx.py
+++ b/influx.py
@@ -83,12 +83,21 @@ if __name__ == "__main__":
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://localhost:4560"
+ login = config['login'] if "login" in config else None
+ api = config['api'] if "api" in config else "rpc"
+
+ # config influxdb
+ influxdb_host = config['influxdb_host'] if "influxdb_host" in config else "localhost"
+ influxdb_port = config['influxdb_port'] if "influxdb_port" in config else 8086
+ influxdb_database = config['database'] if "database" in config else "ejabberd"
+
# init global handler
- metrics = EjabberdMetrics("http://localhost:4560", config['login'])
- client = InfluxDBClient(host='localhost', port=8086, database=config['database'], retries=5)
+ metrics = EjabberdMetrics(url, login, api)
+ client = InfluxDBClient(host=influxdb_host, port=influxdb_port, database=influxdb_database, retries=5)
# create database only once
- client.create_database(config['database'])
+ client.create_database(influxdb_database)
# init influx class
influx = Influx(metrics, client)