Add Infrastructure Audit Tool
This commit is contained in:
25
.gitea/workflows/audit-report.yaml
Normal file
25
.gitea/workflows/audit-report.yaml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
name: Infrastructure Audit
|
||||||
|
run-name: 📊 Running Watchtower & Tools Audit
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
server-report:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.9'
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: pip install -r requirements.txt
|
||||||
|
|
||||||
|
- name: Run Audit Script
|
||||||
|
run: python audit.py
|
||||||
47
audit.py
Normal file
47
audit.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import docker
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
def generate_report():
|
||||||
|
try:
|
||||||
|
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(f"🛡️ ANTIGRAVITY INFRASTRUCTURE REPORT")
|
||||||
|
print(f"📅 Date: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||||||
|
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
|
||||||
|
tags = container.image.tags
|
||||||
|
tag_name = tags[0] if tags else "unknown"
|
||||||
|
# Shorten tag for display
|
||||||
|
if "/" in tag_name:
|
||||||
|
tag_name = tag_name.split("/")[-1]
|
||||||
|
|
||||||
|
print(f"{container.name:<25} {container.status:<15} {tag_name}")
|
||||||
|
|
||||||
|
print("\n" + "="*40)
|
||||||
|
print("✅ Audit Complete.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
generate_report()
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
psycopg2-binary
|
psycopg2-binary
|
||||||
requests
|
requests
|
||||||
|
docker
|
||||||
Reference in New Issue
Block a user