feat: add various infrastructure check and automation scripts
This commit is contained in:
27
scripts/check_idrac4_details.py
Normal file
27
scripts/check_idrac4_details.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import urllib.request
|
||||
import json
|
||||
import ssl
|
||||
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
|
||||
def zabbix_api(method, params, auth=None):
|
||||
payload = {"jsonrpc": "2.0", "method": method, "params": params, "id": 1}
|
||||
if auth: payload["auth"] = auth
|
||||
req = urllib.request.Request("https://zabbix.snarfnet.net/api_jsonrpc.php",
|
||||
data=json.dumps(payload).encode('utf-8'),
|
||||
headers={"Content-Type": "application/json-rpc"})
|
||||
resp = urllib.request.urlopen(req, context=ctx, timeout=10)
|
||||
return json.loads(resp.read().decode('utf-8'))
|
||||
|
||||
auth = zabbix_api("user.login", {"username": "Admin", "password": "zabbix"}).get("result")
|
||||
|
||||
h = zabbix_api("host.get", {
|
||||
"filter": {"host": ["idrac-spacedock4"]},
|
||||
"selectInterfaces": "extend",
|
||||
"selectGroups": "extend",
|
||||
"selectParentTemplates": "extend"
|
||||
}, auth=auth).get("result", [])
|
||||
print(json.dumps(h, indent=2))
|
||||
|
||||
Reference in New Issue
Block a user