Implemented docker health check

This commit is contained in:
2022-12-25 13:40:38 +01:00
parent dd8db239d6
commit ad4a6f8bc0
7 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
[Unit]
Description=Check docker status
OnFailure=systemd-email@%n.service
[Service]
Type=oneshot
ExecStart=/bin/bash /home/administrator/scripts/docker-health-check/docker-health-check.sh

View File

@@ -0,0 +1,10 @@
#!/bin/sh
docker_ps_grep_unhealthy="$(docker ps | grep unhealthy)"
if [ -z "$docker_ps_grep_unhealthy" ]
then
echo "All docker containers are healthy."
exit
else
echo "Some docker containers are unhealthy: $docker_ps_grep_unhealthy"
exit 1
fi

View File

@@ -0,0 +1,8 @@
[Unit]
Description=starts docker-health-check.service
[Timer]
OnCalendar=10:00
[Install]
WantedBy=timers.target