Merge branch 'nightly' of https://github.com/DirtyCajunRice/grafana-scripts into nightly
This commit is contained in:
commit
f2bf301cd1
7 changed files with 54 additions and 6 deletions
|
@ -121,6 +121,8 @@ if __name__ == "__main__":
|
|||
schedule.every(server.request_type_run_seconds).seconds.do(threaded, OMBI.get_request_counts)
|
||||
if server.request_total_counts:
|
||||
schedule.every(server.request_total_run_seconds).seconds.do(threaded, OMBI.get_all_requests)
|
||||
if server.issue_status_counts:
|
||||
schedule.every(server.issue_status_run_seconds).seconds.do(threaded, OMBI.get_issue_counts)
|
||||
|
||||
if CONFIG.sickchill_enabled:
|
||||
for server in CONFIG.sickchill_servers:
|
||||
|
|
|
@ -85,6 +85,8 @@ get_request_type_counts = true
|
|||
request_type_run_seconds = 300
|
||||
get_request_total_counts = true
|
||||
request_total_run_seconds = 300
|
||||
get_issue_status_counts = true
|
||||
issue_status_run_seconds = 300
|
||||
|
||||
[sickchill-1]
|
||||
url = sickchill.domain.tld:8081
|
||||
|
|
|
@ -33,7 +33,7 @@ class GeoIPHandler(object):
|
|||
|
||||
def update(self):
|
||||
today = date.today()
|
||||
dbdate = None
|
||||
|
||||
try:
|
||||
dbdate = date.fromtimestamp(stat(self.dbfile).st_ctime)
|
||||
except FileNotFoundError:
|
||||
|
@ -55,7 +55,6 @@ class GeoIPHandler(object):
|
|||
else:
|
||||
self.logger.debug('Geolite2 DB will update in %s days', abs(td.days))
|
||||
|
||||
|
||||
def download(self):
|
||||
tar_dbfile = abspath(join(self.data_folder, 'GeoLite2-City.tar.gz'))
|
||||
url = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz'
|
||||
|
|
|
@ -66,7 +66,7 @@ class INIParser(object):
|
|||
|
||||
search = (r'(?:([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}|' # domain...
|
||||
r'localhost|' # localhost...
|
||||
r'^[a-zA-Z0-9_-]*|' # hostname only. My soul dies a little every time this is used...
|
||||
r'^[a-zA-Z0-9_-]*|' # hostname only. My soul dies a little every time this is used...
|
||||
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
|
||||
)
|
||||
# Include search for port if it is needed.
|
||||
|
@ -80,7 +80,8 @@ class INIParser(object):
|
|||
valid = match(regex, url_check) is not None
|
||||
if not valid:
|
||||
if inc_port:
|
||||
self.logger.error('%s is invalid in module [%s]! URL must host/IP and port if not 80 or 443. ie. localhost:8080',
|
||||
self.logger.error('%s is invalid in module [%s]! URL must host/IP and '
|
||||
'port if not 80 or 443. ie. localhost:8080',
|
||||
url_check, module)
|
||||
exit(1)
|
||||
else:
|
||||
|
@ -179,9 +180,14 @@ class INIParser(object):
|
|||
|
||||
request_total_run_seconds = self.config.getint(section, 'request_total_run_seconds')
|
||||
|
||||
issue_status_counts = self.config.getboolean(section, 'get_issue_status_counts')
|
||||
|
||||
issue_status_run_seconds = self.config.getint(section, 'issue_status_run_seconds')
|
||||
|
||||
server = OmbiServer(server_id, scheme + url, apikey, verify_ssl, request_type_counts,
|
||||
request_type_run_seconds, request_total_counts,
|
||||
request_total_run_seconds)
|
||||
request_total_run_seconds, issue_status_counts,
|
||||
issue_status_run_seconds)
|
||||
|
||||
if service == 'sickchill':
|
||||
get_missing = self.config.getboolean(section, 'get_missing')
|
||||
|
|
|
@ -3,7 +3,7 @@ from requests import Session, Request
|
|||
from datetime import datetime, timezone
|
||||
|
||||
from varken.helpers import connection_handler, hashit
|
||||
from varken.structures import OmbiRequestCounts, OmbiMovieRequest, OmbiTVRequest
|
||||
from varken.structures import OmbiRequestCounts, OmbiIssuesCounts, OmbiMovieRequest, OmbiTVRequest
|
||||
|
||||
|
||||
class OmbiAPI(object):
|
||||
|
@ -162,3 +162,31 @@ class OmbiAPI(object):
|
|||
]
|
||||
|
||||
self.dbmanager.write_points(influx_payload)
|
||||
|
||||
def get_issue_counts(self):
|
||||
now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
endpoint = '/api/v1/Issues/count'
|
||||
|
||||
req = self.session.prepare_request(Request('GET', self.server.url + endpoint))
|
||||
get = connection_handler(self.session, req, self.server.verify_ssl)
|
||||
|
||||
if not get:
|
||||
return
|
||||
|
||||
requests = OmbiIssuesCounts(**get)
|
||||
influx_payload = [
|
||||
{
|
||||
"measurement": "Ombi",
|
||||
"tags": {
|
||||
"type": "Issues_Counts"
|
||||
},
|
||||
"time": now,
|
||||
"fields": {
|
||||
"pending": requests.pending,
|
||||
"in_progress": requests.inProgress,
|
||||
"resolved": requests.resolved
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
self.dbmanager.write_points(influx_payload)
|
||||
|
|
|
@ -61,6 +61,8 @@ class OmbiServer(NamedTuple):
|
|||
request_type_run_seconds: int = 30
|
||||
request_total_counts: bool = False
|
||||
request_total_run_seconds: int = 30
|
||||
issue_status_counts: bool = False
|
||||
issue_status_run_seconds: int = 30
|
||||
|
||||
|
||||
class TautulliServer(NamedTuple):
|
||||
|
@ -107,6 +109,12 @@ class OmbiRequestCounts(NamedTuple):
|
|||
available: int = 0
|
||||
|
||||
|
||||
class OmbiIssuesCounts(NamedTuple):
|
||||
pending: int = 0
|
||||
inProgress: int = 0
|
||||
resolved: int = 0
|
||||
|
||||
|
||||
class TautulliStream(NamedTuple):
|
||||
rating: str = None
|
||||
transcode_width: str = None
|
||||
|
@ -319,6 +327,7 @@ class TVShow(NamedTuple):
|
|||
sceneEpisodeNumber: int = None
|
||||
sceneSeasonNumber: int = None
|
||||
series: dict = None
|
||||
lastSearchTime: str = None
|
||||
id: int = None
|
||||
|
||||
|
||||
|
|
|
@ -108,6 +108,8 @@ class TautulliAPI(object):
|
|||
"quality": quality,
|
||||
"video_decision": video_decision.title(),
|
||||
"transcode_decision": decision.title(),
|
||||
"transcode_hw_decoding": session.transcode_hw_decoding,
|
||||
"transcode_hw_encoding": session.transcode_hw_encoding,
|
||||
"media_type": session.media_type.title(),
|
||||
"audio_codec": session.audio_codec.upper(),
|
||||
"audio_profile": session.audio_profile.upper(),
|
||||
|
|
Loading…
Reference in a new issue