Create check_docker.sh

This commit is contained in:
David Rotermund 2024-07-16 16:47:34 +02:00 committed by GitHub
parent 3e743c91d1
commit 85b8915757
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

15
check_docker.sh Normal file
View file

@ -0,0 +1,15 @@
#!/bin/bash
# List of expected container names
expected_containers=("vaultwarden" "nginx" "mariadb")
# Email settings
recipient="paserver@uni-bremen.de"
subject="Docker Container Alert"
# Check containers
for container in "${expected_containers[@]}"; do
if ! docker ps --format '{{.Names}}' | grep -q "^$container$"; then
echo "Container $container is not running" | mail -s "$subject" "$recipient"
fi
done