Add 'sonarren'
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 Sonarren queue")
|
||||||
|
print("graph_title Sonarren queue")
|
||||||
|
print("graph_category sonarren_queue")
|
||||||
|
|
||||||
|
print("sonarren_queue_items.label queue items")
|
||||||
|
print("sonarren_queue_items_size.label queue items size")
|
||||||
|
|
||||||
|
print("sonarren_queue_items_downloading.label queue items")
|
||||||
|
print("sonarren_queue_items_downloading_size.label queue items size")
|
||||||
|
|
||||||
|
print("sonarren_queue_items_complete.label queue items warning")
|
||||||
|
print("sonarren_queue_items_complete_size.label queue items size warning")
|
||||||
|
|
||||||
|
print("sonarren_queue_items_warning.label queue items warning")
|
||||||
|
print("sonarren_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 "sonarren_queue_items.value", items
|
||||||
|
print "sonarren_queue_items_size.value", items_size
|
||||||
|
|
||||||
|
print "sonarren_queue_items_downloading.value", downloading
|
||||||
|
print "sonarren_queue_items_downloading_size.value", downloading_size
|
||||||
|
|
||||||
|
print "sonarren_queue_items_complete.value", complete
|
||||||
|
print "sonarren_queue_items_complete_size.value", complete_size
|
||||||
|
|
||||||
|
print "sonarren_queue_items_warning.value", warning
|
||||||
|
print "sonarren_queue_items_warning_size.value", warning_size
|
||||||
Reference in New Issue
Block a user