#!/bin/bash #Agent HeartBeat Fail alert mail. #To solve the problem, you can run this script to the agent server in anywhere. kid=$(ps -ef | grep java | grep -v grep | awk '{print $2}') if [ -z "$(ps -ef | grep java | grep -v grep)" ] then echo "wait 5 seconds ..." sleep 5s nohup java -jar /var/monitor_agent/agentMain.jar /var/monitor_agent/conf 2>&1 > /dev/null & if [ $? == 0 ] then echo "The agent have started successfully!" fi else kill -9 $kid if [ $? == 0 ] then echo "wait 1 minutes ..." sleep 1m echo "Starting agent ..." nohup java -jar /var/monitor_agent/agentMain.jar /var/monitor_agent/conf 2>&1 > /dev/null & if [ $? == 0 ] then echo "The agent have started successfully!" fi else echo "Failed to kill, please try again later." fi fi echo "####################################" ps -ef | grep java | grep -v grep