feat: add various infrastructure check and automation scripts
This commit is contained in:
43
scripts/check_nutserver.py
Normal file
43
scripts/check_nutserver.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import paramiko
|
||||
import sys
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
try:
|
||||
c.connect('14.4.4.44', username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
||||
print("Connected to 14.4.4.44 via key")
|
||||
except Exception as e:
|
||||
print("Key auth failed, trying password:", e)
|
||||
c.connect('14.4.4.44', username='snarf', password='Katzir476!', timeout=10)
|
||||
print("Connected to 14.4.4.44 via password")
|
||||
|
||||
def run(cmd):
|
||||
stdin, stdout, stderr = c.exec_command(cmd)
|
||||
return stdout.read().decode().strip(), stderr.read().decode().strip()
|
||||
|
||||
print("--- Listening ports on nutserver ---")
|
||||
out, _ = run("ss -tulpn | grep 3493 || netstat -tulpn | grep 3493")
|
||||
print(out)
|
||||
|
||||
print("\n--- /etc/nut/upsd.conf ---")
|
||||
out, _ = run("echo 'Katzir476!' | sudo -S cat /etc/nut/upsd.conf | grep -v '^#' | grep -v '^$'")
|
||||
print(out)
|
||||
|
||||
print("\n--- /etc/nut/nut.conf ---")
|
||||
out, _ = run("echo 'Katzir476!' | sudo -S cat /etc/nut/nut.conf | grep -v '^#' | grep -v '^$'")
|
||||
print(out)
|
||||
|
||||
print("\n--- /etc/nut/upsd.users ---")
|
||||
out, _ = run("echo 'Katzir476!' | sudo -S cat /etc/nut/upsd.users | grep -v '^#' | grep -v '^$'")
|
||||
print(out)
|
||||
|
||||
print("\n--- /etc/nut/ups.conf ---")
|
||||
out, _ = run("echo 'Katzir476!' | sudo -S cat /etc/nut/ups.conf | grep -v '^#' | grep -v '^$'")
|
||||
print(out)
|
||||
|
||||
print("\n--- upsc server-closet@localhost ---")
|
||||
out, _ = run("upsc server-closet@localhost")
|
||||
print(out[:300])
|
||||
|
||||
c.close()
|
||||
Reference in New Issue
Block a user