fix(monitoring): make the reported key count self-describing instead of a bare number #109
@@ -197,16 +197,16 @@ def check_admin_key_list():
|
|||||||
# Try to parse the response
|
# Try to parse the response
|
||||||
try:
|
try:
|
||||||
data = json.loads(stdout)
|
data = json.loads(stdout)
|
||||||
# Response is a dict with "keys" field
|
# Response is a dict with "keys" (paginated list) and "total_count" fields
|
||||||
if isinstance(data, dict) and "keys" in data:
|
if isinstance(data, dict) and "keys" in data:
|
||||||
key_count = len(data["keys"])
|
key_count = data.get("total_count", len(data["keys"]))
|
||||||
elif isinstance(data, list):
|
elif isinstance(data, list):
|
||||||
key_count = len(data)
|
key_count = len(data)
|
||||||
else:
|
else:
|
||||||
key_count = 0
|
key_count = 0
|
||||||
if key_count == 0:
|
if key_count == 0:
|
||||||
return "Admin Key List", False, "admin-call-failed (empty response)"
|
return "Admin Key List", False, "admin-call-failed (empty response)"
|
||||||
return "Admin Key List", True, str(key_count) + " keys"
|
return "Admin Key List", True, str(key_count) + " total (" + str(len(data.get("keys", []) if isinstance(data, dict) else data)) + " on page 1)" if isinstance(data, dict) else str(key_count) + " total"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return "Admin Key List", False, "admin-call-failed (unparseable: " + str(e) + ")"
|
return "Admin Key List", False, "admin-call-failed (unparseable: " + str(e) + ")"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user