24 lines
961 B
Python
24 lines
961 B
Python
import requests
|
|
import json
|
|
import urllib3
|
|
urllib3.disable_warnings()
|
|
|
|
auth = ("admin", "Katzir476!!!")
|
|
def prom_query(q):
|
|
url = "https://grafana.snarfnet.net/api/datasources/proxy/1/api/v1/query"
|
|
resp = requests.get(url, params={"query": q}, auth=auth, verify=False, timeout=10)
|
|
return resp.json().get("data", {}).get("result", [])
|
|
|
|
print("--- Testing Aerodrome queries ---")
|
|
print("Nodes:", len(prom_query("node_load1{cluster='aerodrome'}")))
|
|
print("Containers:", len(prom_query("container_last_seen{container!='', instance=~'sninfr2.*'}")))
|
|
|
|
print("\n--- Testing Spaceport queries ---")
|
|
print("Nodes:", len(prom_query("node_load1{cluster='spaceport'}")))
|
|
print("Containers:", len(prom_query("container_last_seen{container!='', cluster='spaceport'}")))
|
|
|
|
print("\n--- Testing Shipyard queries ---")
|
|
print("Nodes:", len(prom_query("node_load1{cluster='shipyard'}")))
|
|
print("Containers:", len(prom_query("container_last_seen{cluster='shipyard'}")))
|
|
|