feat: add infrastructure automation and diagnostic scripts for Zabbix, Nginx, and Authentik
This commit is contained in:
19
scripts/check_two_events.py
Normal file
19
scripts/check_two_events.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import json, ssl, urllib.request
|
||||
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
|
||||
ZABBIX_URL = 'http://140.44.4.60:8888/api_jsonrpc.php'
|
||||
|
||||
payload = {'jsonrpc': '2.0', 'method': 'user.login', 'params': {'username': 'Admin', 'password': 'zabbix'}, 'id': 1}
|
||||
req = urllib.request.Request(ZABBIX_URL, data=json.dumps(payload).encode(), headers={'Content-Type': 'application/json-rpc'})
|
||||
token = json.loads(urllib.request.urlopen(req, context=ctx).read())['result']
|
||||
|
||||
payload = {'jsonrpc': '2.0', 'method': 'event.get', 'params': {'eventids': ['82136', '82113'], 'selectHosts': ['host', 'name']}, 'id': 2}
|
||||
req = urllib.request.Request(ZABBIX_URL, data=json.dumps(payload).encode(), headers={'Content-Type': 'application/json-rpc', 'Authorization': f'Bearer {token}'})
|
||||
events = json.loads(urllib.request.urlopen(req, context=ctx).read())['result']
|
||||
|
||||
for e in events:
|
||||
print(f"Event {e['eventid']}: name={e['name']}, hosts={e.get('hosts')}")
|
||||
|
||||
Reference in New Issue
Block a user