#!/bin/bash # # DB-Check # # /root/bin/check_db.sh $(hostname -s) 3306 root geheimespasswort # unset node_response mysql_host="${1}"; mysql_port="${2}"; mysql_user="${3}"; mysql_pass="${4}"; OPTION="/tmp/check_db.cfg" touch ${OPTION} chmod 0600 ${OPTION} echo " [client] host = localhost port = ${mysql_port} user = ${mysql_user} password = "${mysql_pass}" " > ${OPTION} node_response=$(echo "SHOW GLOBAL VARIABLES LIKE 'hostname';" | mysql --defaults-file=${OPTION} -N | awk '{ print $2 }'); wsrep_state=$(echo "SHOW STATUS LIKE 'wsrep_local_state_comment';" | mysql --defaults-file=${OPTION} -N | awk '{ print $2 }'); rm -f ${OPTION} echo "${mysql_host} ? ${node_response} / ${wsrep_state}" > /tmp/${mysql_host}ma.txt if [ "${wsrep_local_state}" = "4" ] then if [ "${node_response}" == "${mysql_host}" ] then # echo "Hostname matched" exit 0; else # echo "Hostname not matched" exit 1; fi else # echo "Knoten ist nicht synchron" exit 1; fi