Update 'sonarr_queue'
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from sys import argv, exit
|
||||
from subprocess import check_output
|
||||
from re import search, sub
|
||||
from json import loads, dumps
|
||||
from os import environ
|
||||
from requests import get
|
||||
|
||||
if len(argv) > 1:
|
||||
print("graph_vlabel Sonarr queue")
|
||||
print("graph_title Sonarr queue")
|
||||
print("graph_category sonarr_queue")
|
||||
|
||||
print("sonarr_queue_items.label queue items")
|
||||
print("sonarr_queue_items_size.label queue items size")
|
||||
|
||||
print("sonarr_queue_items_downloading.label queue items")
|
||||
print("sonarr_queue_items_downloading_size.label queue items size")
|
||||
|
||||
print("sonarr_queue_items_complete.label queue items warning")
|
||||
print("sonarr_queue_items_complete_size.label queue items size warning")
|
||||
|
||||
print("sonarr_queue_items_warning.label queue items warning")
|
||||
print("sonarr_queue_items_warning_size.label queue items size warning")
|
||||
|
||||
exit()
|
||||
|
||||
response = get(
|
||||
"{}/{}?apikey=".format(environ["host"], "api/queue", environ["apikey"]),
|
||||
headers={"Accept": "application/json"}
|
||||
)
|
||||
|
||||
response.raise_for_status()
|
||||
|
||||
items = 0
|
||||
items_size = 0
|
||||
|
||||
downloading = 0
|
||||
downloading_size = 0
|
||||
|
||||
complete = 0
|
||||
complete_size = 0
|
||||
|
||||
warning = 0
|
||||
warning_size = 0
|
||||
|
||||
for item in response.json():
|
||||
if item["status"] == "Downloading":
|
||||
downloading = downloading + 1
|
||||
downloading_size = downloading_size + item["size"]
|
||||
|
||||
elif item["status"] == "Complete":
|
||||
complete = complete + 1
|
||||
complete_size = complete_size + item["size"]
|
||||
|
||||
if item["trackedDownloadStatus"] == "Warning":
|
||||
warning = warning + 1
|
||||
warning_size = warning_size + item["size"]
|
||||
|
||||
items = items + 1
|
||||
items_size = items_size + item["size"]
|
||||
|
||||
print "sonarr_queue_items.value", items
|
||||
print "sonarr_queue_items_size.value", items_size
|
||||
|
||||
print "sonarr_queue_items_downloading.value", downloading
|
||||
print "sonarr_queue_items_downloading_size.value", downloading_size
|
||||
|
||||
print "sonarr_queue_items_complete.value", complete
|
||||
print "sonarr_queue_items_complete_size.value", complete_size
|
||||
|
||||
print "sonarr_queue_items_warning.value", warning
|
||||
print "sonarr_queue_items_warning_size.value", warning_size
|
||||
Reference in New Issue
Block a user