Initial push
This commit is contained in:
commit
5a9166a410
6 changed files with 264 additions and 0 deletions
42
firewall.py
Normal file
42
firewall.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
import requests
|
||||
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from influxdb import InfluxDBClient
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# noinspection PyUnresolvedReferences
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
current_time = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
|
||||
stats = {
|
||||
"name": 'router',
|
||||
"ip": 'X.X.X.X'
|
||||
}
|
||||
|
||||
stats['token'] = requests.post('https://{}/api/tokenservices'.format(stats['ip']), auth=('username', 'password'),
|
||||
verify=False)
|
||||
stats['headers'] = {'X-Auth-Token': stats['token'].headers['X-Auth-Token']}
|
||||
stats['outside_interface'] = requests.get('https://{}/api/monitoring/device/interfaces/Outside'.format(stats['ip']),
|
||||
headers=stats['headers'], verify=False).json()
|
||||
|
||||
influx_payload = [
|
||||
{
|
||||
"measurement": "bandwidth",
|
||||
"tags": {
|
||||
"interface": "outside"
|
||||
},
|
||||
"time": current_time,
|
||||
"fields": {
|
||||
"upload_bitrate": stats['outside_interface']['outputBitRate'],
|
||||
"download_bitrate": stats['outside_interface']['inputBitRate']
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
influx = InfluxDBClient('grafana.domain.tld', 8086, 'root', 'root', 'firewall')
|
||||
influx.write_points(influx_payload)
|
||||
|
||||
|
42
ombi.py
Normal file
42
ombi.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
import requests
|
||||
from datetime import datetime, timezone
|
||||
from influxdb import InfluxDBClient
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# noinspection PyUnresolvedReferences
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
current_time = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
|
||||
headers = {'Apikey': 'xxxxxxxxxxxxxxxxxxxxxxx'}
|
||||
get_tv_requests = requests.get('https://request.domain.tld/api/v1/Request/tv', headers=headers).json()
|
||||
get_movie_requests = requests.get('https://request.domain.tld/api/v1/Request/movie', 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": "Plex",
|
||||
"tags": {
|
||||
"server": "Ombi",
|
||||
"type": "Requests"
|
||||
},
|
||||
"time": current_time,
|
||||
"fields": {
|
||||
"total": count_movie_requests + count_tv_requests
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
influx = InfluxDBClient('grafana.domain.tld', 8086, 'root', 'root', 'plex')
|
||||
influx.write_points(influx_payload)
|
||||
|
42
radarr.py
Normal file
42
radarr.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
import requests
|
||||
from datetime import datetime, timezone
|
||||
from influxdb import InfluxDBClient
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# noinspection PyUnresolvedReferences
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
current_time = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
|
||||
api_key = 'xxxxxxxxxxxxxxxxxxxxxxxx'
|
||||
headers = {'X-Api-Key': api_key}
|
||||
get_movies = requests.get('https://radarr.domain.tld/api/movie', headers=headers).json()
|
||||
movies = {d['tmdbId']: d for d in get_movies}
|
||||
missing = []
|
||||
influx_payload = []
|
||||
|
||||
for movie in movies.keys():
|
||||
if not movies[movie]['downloaded']:
|
||||
missing.append((movies[movie]['title'], movies[movie]['tmdbId']))
|
||||
|
||||
for movie, id in missing:
|
||||
influx_payload.append(
|
||||
{
|
||||
"measurement": "Plex",
|
||||
"tags": {
|
||||
"server": "Radarr",
|
||||
"type": "Missing",
|
||||
"tmdbId": id
|
||||
},
|
||||
"time": current_time,
|
||||
"fields": {
|
||||
"name": movie
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
influx = InfluxDBClient('grafana.domain.tld', 8086, 'root', 'root', 'plex')
|
||||
influx.write_points(influx_payload)
|
||||
|
39
san.py
Normal file
39
san.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import subprocess
|
||||
import requests
|
||||
import re
|
||||
import psutil
|
||||
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from influxdb import InfluxDBClient
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# noinspection PyUnresolvedReferences
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
current_time = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
|
||||
raid6 = psutil.disk_usage('/mnt')
|
||||
|
||||
influx_payload = [
|
||||
{
|
||||
"measurement": "Storage Servers",
|
||||
"tags": {
|
||||
"server": "SAN3"
|
||||
},
|
||||
"time": current_time,
|
||||
"fields": {
|
||||
"Name": '/mnt',
|
||||
"bytes Used": raid6.used,
|
||||
"bytes Free": raid6.free,
|
||||
"bytes Total": raid6.total,
|
||||
"Utilization": raid6.percent,
|
||||
"IO_Wait": psutil.cpu_times_percent().iowait
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
influx = InfluxDBClient('grafana.domain.tld', 8086, 'root', 'root', 'storage_server')
|
||||
influx.write_points(influx_payload)
|
||||
|
43
sonarr.py
Normal file
43
sonarr.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
import requests
|
||||
from datetime import datetime, timezone
|
||||
from influxdb import InfluxDBClient
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# noinspection PyUnresolvedReferences
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
current_time = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
|
||||
api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
|
||||
headers = {'X-Api-Key': api_key}
|
||||
get_tv_shows = requests.get('https://sonarr.domain.tld/api/wanted/missing/?pageSize=1000',
|
||||
headers=headers).json()['records']
|
||||
tv_shows = {d['id']: d for d in get_tv_shows}
|
||||
missing = []
|
||||
influx_payload = []
|
||||
|
||||
for show in tv_shows.keys():
|
||||
name = '{} - S{}E{}'.format(tv_shows[show]['series']['title'], tv_shows[show]['seasonNumber'],
|
||||
tv_shows[show]['episodeNumber'])
|
||||
missing.append((name, tv_shows[show]['id']))
|
||||
|
||||
for show, id in missing:
|
||||
influx_payload.append(
|
||||
{
|
||||
"measurement": "Plex",
|
||||
"tags": {
|
||||
"server": "Sonarr",
|
||||
"type": "Missing",
|
||||
"sonarrId": id
|
||||
},
|
||||
"time": current_time,
|
||||
"fields": {
|
||||
"name": show
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
influx = InfluxDBClient('grafana.domain.tld', 8086, 'root', 'root', 'plex')
|
||||
influx.write_points(influx_payload)
|
||||
|
56
tautulli.py
Normal file
56
tautulli.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
import requests
|
||||
import geohash
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from influxdb import InfluxDBClient
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||
# noinspection PyUnresolvedReferences
|
||||
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
||||
|
||||
current_time = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
|
||||
activity = requests.get('https://plexpy.domain.tld/api/v2'
|
||||
'?apikey=xxxxxxxxxxxx&cmd=get_activity').json()['response']['data']
|
||||
|
||||
sessions = {d['session_id']: d for d in activity['sessions']}
|
||||
|
||||
influx_payload = [
|
||||
{
|
||||
"measurement": "Plex",
|
||||
"tags": {
|
||||
"server": "Tautulli"
|
||||
},
|
||||
"time": current_time,
|
||||
"fields": {
|
||||
"stream_count": int(activity['stream_count'])
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
for session in sessions.keys():
|
||||
lookup = requests.get('http://freegeoip.net/json/{}'.format(sessions[session]['ip_address_public'])).json()
|
||||
influx_payload.append(
|
||||
{
|
||||
"measurement": "Plex",
|
||||
"tags": {
|
||||
"server": "Tautulli",
|
||||
"type": "Session",
|
||||
"region_code": lookup['region_code']
|
||||
},
|
||||
"time": current_time,
|
||||
"fields": {
|
||||
"name": sessions[session]['friendly_name'],
|
||||
"title": sessions[session]['full_title'],
|
||||
"quality": '{}p'.format(sessions[session]['video_resolution']),
|
||||
"transcode_decision": sessions[session]['transcode_decision'],
|
||||
"location": lookup['city'],
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
influx = InfluxDBClient('grafana.domain.tld', 8086, 'root', 'root', 'plex')
|
||||
influx.write_points(influx_payload)
|
||||
|
Loading…
Reference in a new issue