######################################################################
#### function: check service status
####author:danial_chen
####create date:2020-05-19
####modify date:2020-05-19
######################################################################

## start to check service status ##
pd=$PWD
clustername=`cat $pd/kingdee_hosts |grep clustername | awk -F "=" '{print $2}'`
nginx_ierpport=`cat $pd/kingdee_hosts |grep nginx_ierpport | awk -F "=" '{print $2}' | sed 's/\"//g'`
db_port=`cat $pd/kingdee_hosts |grep db_port | awk -F "=" '{print $2}' | sed 's/\"//g'`

/bin/cp $pd/ansible/service-status.yaml /etc/ansible/service-status.yaml
sed -i s/clustername/$clustername/g /etc/ansible/service-status.yaml
sed -i s/nginx_ierpport/$nginx_ierpport/g /etc/ansible/service-status.yaml
sed -i s/db_port/$db_port/g /etc/ansible/service-status.yaml
/usr/bin/ansible-playbook -i $pd/kingdee_hosts -b /etc/ansible/service-status.yaml > $pd/log/service-status-tmp.log

cat $pd/log/service-status-tmp.log|awk '/"msg":\ \[/,/\]/'|grep -v  "\ \ \ \ ]"|grep -v "\ \ \ \ \"msg\"\:\ \[" |sed 's/\"//g' |sed 's/\,//g' > $pd/log/service-status.log
cat $pd/log/service-status.log
