From f3285bf0fec8b282ee2d15d0e6c9b34b0737e4a8 Mon Sep 17 00:00:00 2001 From: Nis Wechselberg Date: Sun, 9 Dec 2018 16:30:01 +0100 Subject: [PATCH] Added rudimentary arguments --- PyPass.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PyPass.py b/PyPass.py index 8ad69e2..7570afc 100755 --- a/PyPass.py +++ b/PyPass.py @@ -16,13 +16,18 @@ Small script to request data from the portal pass.telekom.de and submit it to InfluxDB """ +import argparse import requests from influxdb import InfluxDBClient REQUEST_API_URL = 'http://pass.telekom.de/api/service/generic/v1/status' REQUEST_HEADERS = {'User-Agent': 'Mozilla/4.0'} -HOST_NAME = "Neutestorf-RasPi" +parser = argparse.ArgumentParser() +parser.add_argument("hostname", help="Hostname of this machine") +parser.add_argument("influxHost", help="Hostname/IP of the InfluxDB machine") +parser.add_argument("database", help="Name of the database to write to") +args = parser.parse_args() # Send http request to telekom page and extract json response response = requests.get(REQUEST_API_URL, headers=REQUEST_HEADERS) @@ -33,7 +38,7 @@ measurement = [ { "measurement": "pass_telekom_de", "tags": { - "host": HOST_NAME + "host": args.hostname }, "fields": { "initialVolume": respJson['initialVolume'], @@ -45,5 +50,5 @@ measurement = [ ] # Send data to InfluxDB -influx = InfluxDBClient(host='10.91.12.10', database='network') +influx = InfluxDBClient(host=args.influxHost, database=args.database) influx.write_points(measurement)