Added check for spent data
This commit is contained in:
parent
f3285bf0fe
commit
c4218e35e0
1 changed files with 27 additions and 13 deletions
40
PyPass.py
40
PyPass.py
|
@ -34,20 +34,34 @@ response = requests.get(REQUEST_API_URL, headers=REQUEST_HEADERS)
|
|||
respJson = response.json()
|
||||
|
||||
# Prepare timedata for database
|
||||
measurement = [
|
||||
{
|
||||
"measurement": "pass_telekom_de",
|
||||
"tags": {
|
||||
"host": args.hostname
|
||||
},
|
||||
"fields": {
|
||||
"initialVolume": respJson['initialVolume'],
|
||||
"usedVolume": respJson['usedVolume'],
|
||||
"remainingSeconds": respJson['remainingSeconds'],
|
||||
"usedAtMillis": respJson['usedAt']
|
||||
if respJson['usedPercentage'] < 100:
|
||||
measurement = [
|
||||
{
|
||||
"measurement": "pass_telekom_de",
|
||||
"tags": {
|
||||
"host": args.hostname
|
||||
},
|
||||
"fields": {
|
||||
"initialVolume": respJson['initialVolume'],
|
||||
"usedVolume": respJson['usedVolume'],
|
||||
"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
|
||||
influx = InfluxDBClient(host=args.influxHost, database=args.database)
|
||||
|
|
Loading…
Reference in a new issue