Docker: Check the running status of Docker container and mail alerts periodically

Source: Internet
Author: User

First create a bash script that sends mail-send_mail.sh:

#!/bin/Bashcurl-S--user'api:key-xxxxxxxxxxxxx'https://api.mailgun.net/v3/xxxxxxx/messages \-F from='Support <[email protected]>'     -F to='xxx <[email protected]>'     -F subject="$mail _subject"     -F text="$mail _text"

The email here is mailgun and can be replaced by a different email provider.

Then create a script to check Docker status-check_docker_status.sh:

!/bin/bashexport mail_subject="Docker running status exception !" " now = 'date +%y-%m-%d#%h:%m:%S ' export mail_text='Docker found in $now stopped running "  PSgrepIDawk'{if (! ( /up/)) {System ("/home/xxx/send_mail.sh")}}'

Then remember to add the send_mail.sh and check_docker_status.sh scripts to the executable properties.

Last added to Crontab:

Crontab-eXX * * * * */home/xxx/check_docker_status. SH

The system checks the Docker status at 0 minutes per hour and sends a message to the specified mailbox once it is not in the up state.

Done

Docker: Check the running status of Docker container and mail alerts periodically

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.