--------------------------------cluster_check_list.conf------------start---------------------
server#1;server#2;https://xxxxxxx/clustercheck.jsp
------------------------------- cluster_check_list.conf-------------end------------------
--------------------------------cluster_check_common.sh------------start---------------------
#!/bin/sh
##############################################################################
# 概要 :
# フェイル名 :cluster_check_common.sh
# 実行ユーザ :
# 設計者 :
# 入力パラメータ :なし
##############################################################################
dir_sh=/work/tools/staging/sh
dir_conf=/work/tools/staging/conf
cat $dir_conf/cluster_check_list.conf | while read line
do
arr=(${line//;/ })
for x in ${arr[2]}; do
sh $dir_sh/cluster_check.sh ${arr[0]} ${arr[1]} ${arr[2]}
done
done
--------------------------------cluster_check_common.sh------------end---------------------
--------------------------------cluster_check.sh------------start---------------------
#!/bin/sh
##############################################################################
# 概要 :
# フェイル名 :cluster_check.sh
# 実行ユーザ :
# 設計者 :
# 入力パラメータ :$1 $2 $3
##############################################################################
Servername1=$1
Servername2=$2
LB_URL=$3
session_id=`curl --connect-timeout 5 --max-time 10 -v $LB_URL 2>&1 | grep "Session ID" |awk '{print $4}'`
session_id1=`GET http://$Servername1:8080/gis/clustercheck.jsp HTTP/1.0 -H "Cookie: JSESSIONID=$session_id" |grep "Session ID" |awk '{print $4}'`
session_id2=`GET http://$Servername2:8080/gis/clustercheck.jsp HTTP/1.0 -H "Cookie: JSESSIONID=$session_id" |grep "Session ID" |awk '{print $4}'`
echo "session_id=$session_id"
echo "session_id1=$session_id1"
echo "session_id2=$session_id2"
if [ "$session_id1"x = "$session_id"x ]&&[ "$session_id2"x = "$session_id"x ];then
echo -e "\033[32m[ $Servername1 and $Servername2 Tomcat cluster is ok.]\033[0m"
else
echo -e "\033[31m[ $Servername1 and $Servername2 Tomcat cluster no ok] \033[0m"
fi
--------------------------------cluster_check.sh------------end---------------------
--------------------------------clustercheck.jsp------------start---------------------
<html><head><title>Tomcat Cluster Check</title></head>
<body>
<h1>Cluster AP#1 Test Page</h1>
<%
out.println("<b>Server Info</b> " + " : " + request.getLocalAddr());
out.println("<b>Session ID</b> " + " : " + session.getId());
%>
</body>
</html>
--------------------------------clustercheck.jsp------------end---------------------