#!/bin/bash


log_file=/etc/keepalived/report.log
COUNT=$(systemctl status nginx | grep -c "active (running)")


if [ "$COUNT" -eq 0 ];then

    echo "[ERROR] moniter nginx failure ! $(date) " >> ${log_file}
    systemctl restart nginx

    sleep 2
    if [ $(systemctl status nginx | grep -c "active (running)") -eq 0 ];then
        echo "[ERROR] restart nginx failed ! $(date) " >> ${log_file}
        killall keepalived
    fi
fi
