feat: add homelab deployment configs, documentation, and automation scripts
This commit is contained in:
41
scripts/check_zabbix_templates.py
Normal file
41
scripts/check_zabbix_templates.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import json
|
||||
import ssl
|
||||
import urllib.request
|
||||
|
||||
ZABBIX_URL = "http://140.44.4.60:8888/api_jsonrpc.php"
|
||||
ZABBIX_USER = "Admin"
|
||||
ZABBIX_PASS = "zabbix"
|
||||
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
|
||||
def zbx_call(method, params, auth=None):
|
||||
payload = {"jsonrpc": "2.0", "method": method, "params": params, "id": 1}
|
||||
headers = {"Content-Type": "application/json-rpc"}
|
||||
if auth:
|
||||
headers["Authorization"] = f"Bearer {auth}"
|
||||
req = urllib.request.Request(ZABBIX_URL, data=json.dumps(payload).encode("utf-8"), headers=headers, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=10, context=ctx) as r:
|
||||
resp = json.loads(r.read().decode("utf-8"))
|
||||
if "error" in resp:
|
||||
raise RuntimeError(f"Zabbix error in {method}: {resp['error']}")
|
||||
return resp["result"]
|
||||
|
||||
auth_token = zbx_call("user.login", {"username": ZABBIX_USER, "password": ZABBIX_PASS})
|
||||
|
||||
# Get host groups
|
||||
groups = zbx_call("hostgroup.get", {"output": ["groupid", "name"]}, auth_token)
|
||||
print("=== Host Groups ===")
|
||||
for g in groups:
|
||||
print(f"ID: {g['groupid']}, Name: {g['name']}")
|
||||
|
||||
# Get ICMP Ping template
|
||||
templates = zbx_call("template.get", {
|
||||
"output": ["templateid", "name"],
|
||||
"filter": {"name": ["ICMP Ping", "Chassis by IPMI", "Dell iDRAC by SNMP", "Ubiquiti UniFi by SNMP"]}
|
||||
}, auth_token)
|
||||
print("\n=== Templates ===")
|
||||
for t in templates:
|
||||
print(f"ID: {t['templateid']}, Name: {t['name']}")
|
||||
|
||||
Reference in New Issue
Block a user