2018-02-12 16:31:38 -08:00
|
|
|
# Do not edit this script. Edit configuration.py
|
2018-02-09 22:40:32 -08:00
|
|
|
import requests
|
|
|
|
from datetime import datetime, timezone
|
|
|
|
from influxdb import InfluxDBClient
|
|
|
|
|
2018-02-12 16:31:38 -08:00
|
|
|
import configuration
|
2018-02-09 22:40:32 -08:00
|
|
|
|
|
|
|
current_time = datetime.now(timezone.utc).astimezone().isoformat()
|
|
|
|
|
2018-02-12 16:31:38 -08:00
|
|
|
headers = {'Apikey': configuration.ombi_api_key}
|
|
|
|
get_tv_requests = requests.get('{}/api/v1/Request/tv'.format(configuration.ombi_url), headers=headers).json()
|
|
|
|
get_movie_requests = requests.get('{}/api/v1/Request/movie'.format(configuration.ombi_url), headers=headers).json()
|
2018-02-09 22:40:32 -08:00
|
|
|
|
|
|
|
count_movie_requests = 0
|
|
|
|
count_tv_requests = 0
|
|
|
|
|
|
|
|
for show in get_tv_requests:
|
2018-02-12 16:31:38 -08:00
|
|
|
count_tv_requests += 1
|
2018-02-09 22:40:32 -08:00
|
|
|
|
|
|
|
for movie in get_movie_requests:
|
2018-02-12 16:31:38 -08:00
|
|
|
count_movie_requests += 1
|
2018-02-09 22:40:32 -08:00
|
|
|
|
|
|
|
influx_payload = [
|
|
|
|
{
|
2018-02-09 23:46:58 -08:00
|
|
|
"measurement": "Ombi",
|
2018-02-09 22:40:32 -08:00
|
|
|
"tags": {
|
|
|
|
"type": "Requests"
|
|
|
|
},
|
|
|
|
"time": current_time,
|
|
|
|
"fields": {
|
|
|
|
"total": count_movie_requests + count_tv_requests
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2018-02-12 16:31:38 -08:00
|
|
|
influx = InfluxDBClient(configuration.grafana_url, configuration.grafana_port, configuration.grafana_username,
|
|
|
|
configuration.grafana_password, configuration.ombi_grafana_db_name)
|
2018-02-09 22:40:32 -08:00
|
|
|
influx.write_points(influx_payload)
|
|
|
|
|