Initial version
This commit is contained in:
commit
c14cb914ee
1 changed files with 41 additions and 0 deletions
41
PyPass.py
Normal file
41
PyPass.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# pylint: disable=C0103
|
||||
|
||||
"""
|
||||
Python Telekom Pass Parser
|
||||
|
||||
Small script to request data from the portal pass.telekom.de and
|
||||
submit it to InfluxDB
|
||||
"""
|
||||
|
||||
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"
|
||||
|
||||
# Send http request to telekom page and extract json response
|
||||
response = requests.get(REQUEST_API_URL, headers=REQUEST_HEADERS)
|
||||
respJson = response.json()
|
||||
|
||||
# Prepare timedata for database
|
||||
measurement = [
|
||||
{
|
||||
"measurement": "pass_telekom_de",
|
||||
"tags": {
|
||||
"host": HOST_NAME
|
||||
},
|
||||
"fields": {
|
||||
"initialVolume": respJson['initialVolume'],
|
||||
"usedVolume": respJson['usedVolume'],
|
||||
"remainingSeconds": respJson['remainingSeconds']
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
# Send data to InfluxDB
|
||||
influx = InfluxDBClient(host='10.91.12.10', database='network')
|
||||
influx.write_points(measurement)
|
Loading…
Reference in a new issue