ported ombi

This commit is contained in:
Nicholas St. Germain 2018-12-01 22:26:44 -06:00
parent c3c0381fe1
commit 818f4bea7c
12 changed files with 137 additions and 225 deletions

View file

@ -1,49 +0,0 @@
'''
Notes:
- Domains should be either http(s)://subdomain.domain.com or http(s)://domain.com/url_suffix
- Sonarr + Radarr scripts support multiple servers. You can remove the second
server by putting a # in front of the line.
- tautulli_failback_ip, This is used when there is no IP listed in tautulli.
This can happen when you are streaming locally. This is usually your public IP.
'''
########################### INFLUXDB CONFIG ###########################
influxdb_url = 'influxdb.domain.tld'
influxdb_port = 8086
influxdb_username = ''
influxdb_password = ''
############################ SONARR CONFIG ############################
sonarr_server_list = [
('https://sonarr1.domain.tld', 'xxxxxxxxxxxxxxx', '1'),
('https://sonarr2.domain.tld', 'xxxxxxxxxxxxxxx', '2'),
#('https://sonarr3.domain.tld', 'xxxxxxxxxxxxxxx', '3')
]
sonarr_influxdb_db_name = 'plex'
############################ RADARR CONFIG ############################
radarr_server_list = [
('https://radarr1.domain.tld', 'xxxxxxxxxxxxxxx', '1'),
('https://radarr2.domain.tld', 'xxxxxxxxxxxxxxx', '2'),
#('https://radarr3.domain.tld', 'xxxxxxxxxxxxxxx', '3')
]
radarr_influxdb_db_name = 'plex'
############################ OMBI CONFIG ##############################
ombi_url = 'https://ombi.domain.tld'
ombi_api_key = 'xxxxxxxxxxxxxxx'
ombi_influxdb_db_name = 'plex'
########################## TAUTULLI CONFIG ############################
tautulli_url = 'https://tautulli.domain.tld'
tautulli_api_key = 'xxxxxxxxxxxxxxx'
tautulli_failback_ip = ''
tautulli_influxdb_db_name = 'plex'
########################## FIREWALL CONFIG ############################
asa_url = 'https://firewall.domain.tld'
asa_username = 'cisco'
asa_password = 'cisco'
asa_influxdb_db_name = 'asa'

View file

@ -1,49 +0,0 @@
'''
Notes:
- Domains should be either http(s)://subdomain.domain.com or http(s)://domain.com/url_suffix
- Sonarr + Radarr scripts support multiple servers. You can remove the second
server by putting a # in front of the line.
- tautulli_failback_ip, This is used when there is no IP listed in tautulli.
This can happen when you are streaming locally. This is usually your public IP.
'''
########################### INFLUXDB CONFIG ###########################
influxdb_url = 'influxdb.domain.tld'
influxdb_port = 8086
influxdb_username = ''
influxdb_password = ''
############################ SONARR CONFIG ############################
sonarr_server_list = [
('https://sonarr1.domain.tld', 'xxxxxxxxxxxxxxx', '1'),
('https://sonarr2.domain.tld', 'xxxxxxxxxxxxxxx', '2'),
#('https://sonarr3.domain.tld', 'xxxxxxxxxxxxxxx', '3')
]
sonarr_influxdb_db_name = 'plex'
############################ RADARR CONFIG ############################
radarr_server_list = [
('https://radarr1.domain.tld', 'xxxxxxxxxxxxxxx', '1'),
('https://radarr2.domain.tld', 'xxxxxxxxxxxxxxx', '2'),
#('https://radarr3.domain.tld', 'xxxxxxxxxxxxxxx', '3')
]
radarr_influxdb_db_name = 'plex'
############################ OMBI CONFIG ##############################
ombi_url = 'https://ombi.domain.tld'
ombi_api_key = 'xxxxxxxxxxxxxxx'
ombi_influxdb_db_name = 'plex'
########################## TAUTULLI CONFIG ############################
tautulli_url = 'https://tautulli.domain.tld'
tautulli_api_key = 'xxxxxxxxxxxxxxx'
tautulli_failback_ip = ''
tautulli_influxdb_db_name = 'plex'
########################## FIREWALL CONFIG ############################
asa_url = 'https://firewall.domain.tld'
asa_username = 'cisco'
asa_password = 'cisco'
asa_influxdb_db_name = 'asa'

View file

@ -1,11 +0,0 @@
### Modify paths as appropriate. python3 is located in different places for different users. (`which python3` will give you the path)
### to edit your crontab entry, do not modify /var/spool/cron/crontabs/<user> directly, use `crontab -e`
### Crontabs require an empty line at the end or they WILL not run. Make sure to have 2 lines to be safe
###
* * * * * /usr/bin/python3 /path-to-grafana-scripts/ombi.py
* * * * * ( sleep 30 ; /usr/bin/python3 /path-to-grafana-scripts/ombi.py )
* * * * * /usr/bin/python3 /path-to-grafana-scripts/taurulli.py
* * * * * ( sleep 30 ; /usr/bin/python3 /path-to-grafana-scripts/tautulli.py )
*/30 * * * * /usr/bin/python3 /path-to-grafana-scripts/radarr.py
*/30 * * * * /usr/bin/python3 /path-to-grafana-scripts/sonarr.py
#*/30 * * * * /usr/bin/python3 /path-to-grafana-scripts/sickrage.py

View file

@ -1,87 +0,0 @@
# Do not edit this script. Edit configuration.py
import sys
import requests
from datetime import datetime, timezone
from influxdb import InfluxDBClient
import argparse
from argparse import RawTextHelpFormatter
from Legacy import configuration
headers = {'Apikey': configuration.ombi_api_key}
def now_iso():
now_iso = datetime.now(timezone.utc).astimezone().isoformat()
return now_iso
def influx_sender(influx_payload):
influx = InfluxDBClient(configuration.influxdb_url, configuration.influxdb_port, configuration.influxdb_username,
configuration.influxdb_password, configuration.ombi_influxdb_db_name)
influx.write_points(influx_payload)
def get_total_requests():
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()
count_movie_requests = 0
count_tv_requests = 0
for show in get_tv_requests:
count_tv_requests += 1
for movie in get_movie_requests:
count_movie_requests += 1
influx_payload = [
{
"measurement": "Ombi",
"tags": {
"type": "Request_Total"
},
"time": now_iso(),
"fields": {
"total": count_movie_requests + count_tv_requests
}
}
]
return influx_payload
def get_request_counts():
get_request_counts = requests.get('{}/api/v1/Request/count'.format(configuration.ombi_url), headers=headers).json()
influx_payload = [
{
"measurement": "Ombi",
"tags": {
"type": "Request_Counts"
},
"time": now_iso(),
"fields": {
"pending": int(get_request_counts['pending']),
"approved": int(get_request_counts['approved']),
"available": int(get_request_counts['available'])
}
}
]
return influx_payload
if __name__ == "__main__":
parser = argparse.ArgumentParser(prog='Ombi stats operations',
description='Script to aid in data gathering from Ombi', formatter_class=RawTextHelpFormatter)
parser.add_argument("--total", action='store_true',
help='Get the total count of all requests')
parser.add_argument("--counts", action='store_true',
help='Get the count of pending, approved, and available requests')
opts = parser.parse_args()
if opts.total:
influx_sender(get_total_requests())
elif opts.counts:
influx_sender(get_request_counts())
elif len(sys.argv) == 1:
parser.print_help(sys.stderr)
sys.exit(1)