Feature: Add Watchtower Audit
Some checks failed
Infrastructure Audit / audit (push) Failing after 13s

This commit is contained in:
serhiimosiiash
2025-12-19 14:23:39 +02:00
parent 367d39fb03
commit 10a440aaab
2 changed files with 33 additions and 52 deletions

View File

@@ -1,21 +1,20 @@
name: Sanity Check name: Infrastructure Audit
run-name: 🟢 System Health Check run-name: 📊 Server Status Report
on: [push] on: [push]
jobs: jobs:
health-check: audit:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container:
image: docker:cli # Використовуємо образ з Docker клієнтом!
volumes:
- /var/run/docker.sock:/var/run/docker.sock # Даємо доступ до докера хоста
steps: steps:
- name: 📥 Check out repository - name: 📥 Check out repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: 🐍 Run Sanity Script - name: 🐍 Run Audit Script
# Встановлюємо python прямо в docker контейнері
run: | run: |
# Встановлюємо python3, якщо його немає (на всяк випадок) apk add --no-cache python3
if ! command -v python3 &> /dev/null; then python3 audit.py
echo "Installing Python..."
apt-get update && apt-get install -y python3
fi
# Запускаємо скрипт
python3 sanity_check.py

View File

@@ -1,47 +1,29 @@
import docker import os
import datetime import datetime
def generate_report(): # Простий спосіб перевірити докер без важких бібліотек
try: def check_docker():
client = docker.from_env()
except Exception as e:
print(f"❌ CRITICAL: Cannot connect to Docker. Is the socket mounted?\n{e}")
return
print("="*40) print("="*40)
print(f"🛡️ ANTIGRAVITY INFRASTRUCTURE REPORT") print(f"🛡️ INFRASTRUCTURE REPORT")
print(f"📅 Date: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") print(f"📅 {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print("="*40) print("="*40)
# 1. Check Watchtower
print("\n🔍 CHECKING WATCHTOWER:")
try:
wt = client.containers.get('watchtower')
status_icon = "🟢" if wt.status == 'running' else "🔴"
print(f"{status_icon} Status: {wt.status.upper()}")
print(f"⏱️ Uptime: {wt.attrs['State']['StartedAt']}")
except docker.errors.NotFound:
print("🔴 Watchtower container NOT FOUND on this server!")
except Exception as e:
print(f"⚠️ Error checking Watchtower: {e}")
# 2. List All Tools
print("\n🛠️ ACTIVE TOOLSET STATUS:")
print(f"{'CONTAINER NAME':<25} {'STATUS':<15} {'IMAGE TAG'}")
print("-" * 60)
for container in client.containers.list(): # Перевіряємо запущені контейнери через системну команду
# Get image tag safely stream = os.popen('docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"')
tags = container.image.tags output = stream.read()
tag_name = tags[0] if tags else "unknown"
# Shorten tag for display if not output:
if "/" in tag_name: print("❌ Error: Cannot connect to Docker or no containers running.")
tag_name = tag_name.split("/")[-1] return
print(f"{container.name:<25} {container.status:<15} {tag_name}") print(output)
print("\n" + "="*40) if "watchtower" in output:
print("✅ Audit Complete.") print("\n✅ WATCHTOWER IS ACTIVE AND MONITORING.")
else:
print("\n⚠️ WATCHTOWER NOT FOUND!")
print("="*40)
if __name__ == "__main__": if __name__ == "__main__":
generate_report() check_docker()