feat: add infrastructure automation scripts and master improvement plan
This commit is contained in:
36
scripts/verify_chrony_servers.py
Normal file
36
scripts/verify_chrony_servers.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import os
|
||||
import sys
|
||||
import paramiko
|
||||
|
||||
sys.stdout.reconfigure(encoding="utf-8")
|
||||
pkey = paramiko.Ed25519Key.from_private_key_file(os.path.expanduser('~/.ssh/id_ed25519_snarfnet'))
|
||||
|
||||
SERVERS = [
|
||||
("aerodrome-ctl01 (Primary)", "140.44.4.11", "root"),
|
||||
("nutserver (Secondary)", "14.4.4.44", "snarf"),
|
||||
]
|
||||
|
||||
for name, ip, user in SERVERS:
|
||||
print(f"\n==================================================")
|
||||
print(f"VERIFYING CHRONY SERVER: {name} [{ip}]")
|
||||
print(f"==================================================")
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
try:
|
||||
client.connect(ip, username=user, pkey=pkey, timeout=10)
|
||||
cmd = """
|
||||
if [ "$(id -u)" -ne 0 ]; then SUDO="sudo"; else SUDO=""; fi
|
||||
echo "=== TRACKING ==="
|
||||
$SUDO chronyc tracking
|
||||
echo "=== SOURCES ==="
|
||||
$SUDO chronyc sources -v
|
||||
echo "=== CONNECTED CLIENTS ==="
|
||||
$SUDO chronyc clients
|
||||
"""
|
||||
stdin, stdout, stderr = client.exec_command(cmd)
|
||||
print(stdout.read().decode())
|
||||
except Exception as e:
|
||||
print(f"Error on {name}: {e}")
|
||||
finally:
|
||||
client.close()
|
||||
|
||||
Reference in New Issue
Block a user