diff --git a/Varken.py b/Varken.py index 20aea2b..c157646 100644 --- a/Varken.py +++ b/Varken.py @@ -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: diff --git a/data/varken.example.ini b/data/varken.example.ini index 80b9e81..bbb2ceb 100644 --- a/data/varken.example.ini +++ b/data/varken.example.ini @@ -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 diff --git a/varken/iniparser.py b/varken/iniparser.py index c920d96..beb4d3f 100644 --- a/varken/iniparser.py +++ b/varken/iniparser.py @@ -179,9 +179,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') diff --git a/varken/ombi.py b/varken/ombi.py index 6230170..7299273 100644 --- a/varken/ombi.py +++ b/varken/ombi.py @@ -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) \ No newline at end of file diff --git a/varken/structures.py b/varken/structures.py index bfc297c..4916fee 100644 --- a/varken/structures.py +++ b/varken/structures.py @@ -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): @@ -106,6 +108,11 @@ class OmbiRequestCounts(NamedTuple): approved: int = 0 available: int = 0 +class OmbiIssuesCounts(NamedTuple): + pending: int = 0 + inProgress: int = 0 + resolved: int = 0 + class TautulliStream(NamedTuple): rating: str = None