feat: add infrastructure automation scripts and master improvement plan

This commit is contained in:
2026-11-02 03:07:29 -05:00
parent d1a3ba988a
commit 9c3de8bb4d
94 changed files with 3232 additions and 49 deletions

View File

@@ -0,0 +1,30 @@
import json
import ssl
import urllib.request
ZABBIX_URL = "https://zabbix.snarfnet.net/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_req(method: str, params: dict, auth: str = 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:
return json.loads(r.read().decode("utf-8"))["result"]
token = zbx_req("user.login", {"username": ZABBIX_USER, "password": ZABBIX_PASS})
probs = zbx_req("problem.get", {
"output": ["eventid", "name", "severity"],
"search": {"name": "time"},
}, auth=token)
print(f"Current active time problems in Zabbix: {len(probs)}")
for p in probs:
print(f" {p['eventid']}: {p['name']} [sev={p['severity']}]")