36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
import paramiko
|
|
|
|
SSH_KEY = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("140.44.4.11", username="root", key_filename=SSH_KEY, timeout=10)
|
|
|
|
pod = "uptime-kuma-2-1756668961-5d74fcf9d-hm2xr"
|
|
|
|
# 1. Attach Discord notification (id: 1) to monitors 57 and 94
|
|
sql = """
|
|
USE kuma;
|
|
|
|
-- Attach Discord notification (1) to monitors 57 and 94 if not already attached
|
|
INSERT IGNORE INTO monitor_notification (monitor_id, notification_id) VALUES (57, 1);
|
|
INSERT IGNORE INTO monitor_notification (monitor_id, notification_id) VALUES (94, 1);
|
|
|
|
-- Set Discord Notification (1) to active and is_default = 1 so all future monitors get Discord alerts!
|
|
UPDATE notification SET active = 1, is_default = 1 WHERE id = 1;
|
|
|
|
-- Check notifications for 57 and 94
|
|
SELECT mn.*, m.name, n.name as notif_name FROM monitor_notification mn
|
|
JOIN monitor m ON mn.monitor_id=m.id
|
|
JOIN notification n ON mn.notification_id=n.id
|
|
WHERE mn.monitor_id IN (57, 94);
|
|
"""
|
|
|
|
cmd = f'kubectl exec -n monitoring {pod} -- mariadb -u root --socket=/app/data/run/mariadb.sock kuma -e "{sql}"'
|
|
_, o, e = c.exec_command(cmd)
|
|
print(o.read().decode())
|
|
if e.read().decode():
|
|
print("ERR:", e.read().decode())
|
|
|
|
c.close()
|
|
|