Commit c5b5b498 by Adi Amir

add check for system down status

parent 14af8e57
Showing with 31 additions and 11 deletions
...@@ -33,22 +33,28 @@ check_docker_up_status() { ...@@ -33,22 +33,28 @@ check_docker_up_status() {
NUM_OF_COMPONENTS=`/usr/local/bin/docker-compose -f $DOCKER_FILE ps | grep 'docker_' | wc -l` NUM_OF_COMPONENTS=`/usr/local/bin/docker-compose -f $DOCKER_FILE ps | grep 'docker_' | wc -l`
NUM_OF_UP_COMPONENTS=`/usr/local/bin/docker-compose -f $DOCKER_FILE ps | grep 'docker_' | grep Up | wc -l` NUM_OF_UP_COMPONENTS=`/usr/local/bin/docker-compose -f $DOCKER_FILE ps | grep 'docker_' | grep Up | wc -l`
if [ $NUM_OF_UP_COMPONENTS -eq $NUM_OF_COMPONENTS ]; DOCKER_STATUS="OK"
if [ $NUM_OF_COMPONENTS -eq 0 ];
then
DOCKER_STATUS="FAIL"
SYS_STATUS="FAIL"
echo -e "\e[31mERROR: ${DOCKER_FILE} is down\e[0m"
send_system_down_alert
return
fi
if [ $NUM_OF_UP_COMPONENTS -ne $NUM_OF_COMPONENTS ];
then then
DOCKER_STATUS="OK"
else
DOCKER_STATUS="FAIL" DOCKER_STATUS="FAIL"
SYS_STATUS="FAIL" SYS_STATUS="FAIL"
echo -e "\e[31mERROR: Found status errors in ${DOCKER_FILE}\e[0m"
send_docker_status_alert
return
fi; fi;
if [ "$DOCKER_STATUS" == "FAIL" ]
then echo -e "\e[32m${DOCKER_FILE} is up and running!\e[0m"
echo -e "\e[31mERROR: Found status errors in ${DOCKER_FILE}\e[0m"
send_docker_status_alert
else
echo -e "\e[32m${DOCKER_FILE} is up and running!\e[0m"
fi
} }
send_docker_status_alert() { send_docker_status_alert() {
...@@ -66,6 +72,20 @@ send_docker_status_alert() { ...@@ -66,6 +72,20 @@ send_docker_status_alert() {
send_alert send_alert
} }
send_system_down_alert() {
# title
HOST_NAME=`cat /proc/sys/kernel/hostname`
EMAIL_TITLE="MCX-ALERT(host:${HOST_NAME}) docker ${DOCKER_FILE} is down!"
# message
cat /dev/null > alert-msg.txt
echo -e "docker ${DOCKER_FILE} is down" >> alert-msg.txt
echo " " >> alert-msg.txt
send_alert
}
send_alert() { send_alert() {
echo "To: ipgallery.alert@gmail.com" >> alert-mail.txt echo "To: ipgallery.alert@gmail.com" >> alert-mail.txt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment