Monitoring docker containers and send an email for notifying issues.
cd /opt
git clone git@github.com:oriolrius/docker-monitoring.git .
This is a very simple shell script which monitors critical server services.
-
Copy the file scripts/config.example to scripts/config.
-
Edit the file and change variable parameters to your settings:
EMAIL_NOTIFICATION='user@example.tld' SERVICES="docker.service dbus.service fail2ban.service ssh.service systemd-networkd.service zerotier-one.service" HOSTNAME="your_hostname"
-
Add this script to the crontab:
*/5 * * * * /opt/monitoring/scripts/services.sh > /var/log/monitoring-services.log 2>&1
NOTE: Remember it's a good practice to configure SSMTP or any other SMTP relay mail server for receiving system messages.
-
Go to the workdirectory where you cloned the code
cd /opt/monitoring
-
Build the docker-monitoring container
docker-compose build
-
Create your own configuration file
cp config/example.json config/default.json
-
Edit config/default.json with your data, just fill the variables.
{ "SPARKPOST_API_KEY": "your_sparkpost_api_key", "TO": "user@example.tld", "FROM": "user@example.tld", "HOSTNAME": "your_hostname" }
docker-compose up -d
docker-compose logs -f
Oriol Rius oriol@joor.net https://oriolrius.cat https://oriolrius.me