feat: add various infrastructure check and automation scripts
This commit is contained in:
71
scripts/deploy_shipyard_monitoring.py
Normal file
71
scripts/deploy_shipyard_monitoring.py
Normal file
@@ -0,0 +1,71 @@
|
||||
import paramiko
|
||||
import sys
|
||||
import time
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect('140.44.4.71', username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
||||
|
||||
compose = """version: '3.8'
|
||||
|
||||
services:
|
||||
node-exporter:
|
||||
image: prom/node-exporter:v1.8.2
|
||||
command:
|
||||
- '--path.procfs=/host/proc'
|
||||
- '--path.sysfs=/host/sys'
|
||||
- '--path.rootfs=/host/root'
|
||||
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
|
||||
volumes:
|
||||
- /proc:/host/proc:ro
|
||||
- /sys:/host/sys:ro
|
||||
- /:/host/root:ro
|
||||
ports:
|
||||
- target: 9100
|
||||
published: 9100
|
||||
protocol: tcp
|
||||
mode: host
|
||||
deploy:
|
||||
mode: global
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
|
||||
cadvisor:
|
||||
image: gcr.io/cadvisor/cadvisor:v0.49.1
|
||||
command:
|
||||
- '--housekeeping_interval=10s'
|
||||
- '--docker_only=true'
|
||||
- '--disable_metrics=disk,tcp,udp,percpu,sched,process'
|
||||
volumes:
|
||||
- /:/rootfs:ro
|
||||
- /var/run:/var/run:ro
|
||||
- /sys:/sys:ro
|
||||
- /var/lib/docker/:/var/lib/docker:ro
|
||||
- /dev/disk/:/dev/disk:ro
|
||||
ports:
|
||||
- target: 8080
|
||||
published: 8080
|
||||
protocol: tcp
|
||||
mode: host
|
||||
deploy:
|
||||
mode: global
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
"""
|
||||
|
||||
sftp = c.open_sftp()
|
||||
with sftp.file('/tmp/monitoring-stack.yaml', 'w') as f:
|
||||
f.write(compose)
|
||||
sftp.close()
|
||||
|
||||
stdin, stdout, stderr = c.exec_command("echo 'Katzir476!' | sudo -S docker stack deploy -c /tmp/monitoring-stack.yaml monitoring")
|
||||
print("Deploy output:\n", stdout.read().decode().strip())
|
||||
print("Deploy err:\n", stderr.read().decode().strip())
|
||||
|
||||
time.sleep(5)
|
||||
stdin, stdout, _ = c.exec_command("echo 'Katzir476!' | sudo -S docker stack services monitoring")
|
||||
print("Stack services:\n", stdout.read().decode().strip())
|
||||
|
||||
c.close()
|
||||
|
||||
Reference in New Issue
Block a user