Added check for spent data

This commit is contained in:
Nis Wechselberg 2019-04-30 18:32:31 +02:00
parent f3285bf0fe
commit c4218e35e0

View file

@ -34,20 +34,34 @@ response = requests.get(REQUEST_API_URL, headers=REQUEST_HEADERS)
respJson = response.json() respJson = response.json()
# Prepare timedata for database # Prepare timedata for database
measurement = [ if respJson['usedPercentage'] < 100:
{ measurement = [
"measurement": "pass_telekom_de", {
"tags": { "measurement": "pass_telekom_de",
"host": args.hostname "tags": {
}, "host": args.hostname
"fields": { },
"initialVolume": respJson['initialVolume'], "fields": {
"usedVolume": respJson['usedVolume'], "initialVolume": respJson['initialVolume'],
"remainingSeconds": respJson['remainingSeconds'], "usedVolume": respJson['usedVolume'],
"usedAtMillis": respJson['usedAt'] "remainingSeconds": respJson['remainingSeconds'],
"usedAtMillis": respJson['usedAt']
}
} }
} ]
] else:
measurement = [
{
"measurement": "pass_telekom_de",
"tags": {
"host": args.hostname
},
"fields": {
"remainingSeconds": respJson['remainingSeconds'],
"usedAtMillis": respJson['usedAt']
}
}
]
# Send data to InfluxDB # Send data to InfluxDB
influx = InfluxDBClient(host=args.influxHost, database=args.database) influx = InfluxDBClient(host=args.influxHost, database=args.database)