Linux-공통/Linux-공통__shell-script

서비스 체크하기

말하는감자 2019. 10. 2. 11:51
get_pid_list=$(ps -eaf | grep es.ini | grep -v grep | awk '{print $ 2}')
filter_pid='' read -ra pids<<<"$get_pid_list"
ps=${pids[0]}
echo "PID is "${ps}

status_result=$(curl -L -k -s -o /dev/null -w "%{http_code}\n" 서비스호출주소http://localhost웅앵)
echo "curl result is "${status_result}

#만약 pid가 없으면서 status result가 502라면
if [ -n {ps} -a ${status_result} -eq 502 ];then
        echo "메세지"
        kill -9 ${ps}
        해야할일 랄랄랄
elif [ ${status_result} -eq 502 ];then
        echo "메세지"
        해야할일 >_<
else
        echo "ALL STATUS NORMAL"
fi