From f5ac2a26f1ff86d94fa740933d4d50e91b185535 Mon Sep 17 00:00:00 2001 From: Michelle Date: Wed, 15 Apr 2026 11:14:41 +0200 Subject: [PATCH] rewrite to use mariadb instead of mysql --- check_galera_cluster | 52 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/check_galera_cluster b/check_galera_cluster index dad46b1..d3adea2 100755 --- a/check_galera_cluster +++ b/check_galera_cluster @@ -29,15 +29,15 @@ print_help() { echo "" echo "Options:" echo " u)" - echo " MySQL user." + echo " MariaDB user." echo " p)" - echo " MySQL password." + echo " MariaDB password." echo " H)" - echo " MySQL host." + echo " MariaDB host." echo " P)" - echo " MySQL port." + echo " MariaDB port." echo " m)" - echo " MySQL extra my.cnf configuration file." + echo " MariaDB extra my.cnf configuration file." echo " w)" echo " Sets minimum number of nodes in the cluster when WARNING is raised. (default is same as critical)." echo " c)" @@ -67,7 +67,7 @@ check_executable() { fi } -check_executable mysql +check_executable mariadb check_executable bc while getopts “hvu:p:H:P:w:c:f:m:s:0” OPTION; do @@ -81,19 +81,19 @@ while getopts “hvu:p:H:P:w:c:f:m:s:0” OPTION; do exit $ST_UK ;; u) - mysqluser=$OPTARG + mariadbuser=$OPTARG ;; p) password=$OPTARG ;; H) - mysqlhost=$OPTARG + mariadbhost=$OPTARG ;; P) port=$OPTARG ;; m) - myconfig=$OPTARG + mariadbconfig=$OPTARG ;; w) warn=$OPTARG @@ -128,49 +128,49 @@ create_param() { fi } -param_mysqlhost=$(create_param -h "$mysqlhost") +param_mariadbhost=$(create_param -h "$mariadbhost") param_port=$(create_param -P "$port") -param_mysqluser=$(create_param -u "$mysqluser") +param_mariadbuser=$(create_param -u "$mariadbuser") param_password=$(create_param -p "$password") -param_configfile=$(create_param --defaults-extra-file= "$myconfig") -export MYSQL_PWD=$password +param_configfile=$(create_param --defaults-extra-file= "$mariadbconfig") +export MARIADB_PWD=$password -param_mysql="$param_mysqlhost $param_port $param_mysqluser $param_configfile" +param_mariadb="$param_mariadbhost $param_port $param_mariadbuser $param_configfile" # # verify the database connection # -mysql $param_mysql -B -N -e '\s;' >/dev/null 2>&1 || { - echo "CRITICAL: mysql connection check failed" +mariadb $param_mariadb -B -N -e '\s;' >/dev/null 2>&1 || { + echo "CRITICAL: mariadb connection check failed" exit $ST_CR } # -# retrieve the mysql status +# retrieve the mariadb status # -rMysqlStatus=$(mysql $param_mysql -B -N -e "show status like 'wsrep_%';") +rMariadbStatus=$(mariadb $param_mariadb -B -N -e "show status like 'wsrep_%';") # # verify that the node is part of a cluster # -rClusterStateUuid=$(echo "$rMysqlStatus" | awk '/wsrep_cluster_state_uuid/ {print $2}') +rClusterStateUuid=$(echo "$rMariadbStatus" | awk '/wsrep_cluster_state_uuid/ {print $2}') if [ -z "$rClusterStateUuid" ]; then echo "CRITICAL: node is not part of a cluster" exit $ST_CR fi -rClusterSize=$(echo "$rMysqlStatus" | awk '/wsrep_cluster_size/ {print $2}') -rClusterStatus=$(echo "$rMysqlStatus" | awk '/wsrep_cluster_status/ {print $2}') # Primary -rFlowControl=$(echo "$rMysqlStatus" | awk '/wsrep_flow_control_paused\t/ {print $2}') # < 0.1 +rClusterSize=$(echo "$rMariadbStatus" | awk '/wsrep_cluster_size/ {print $2}') +rClusterStatus=$(echo "$rMariadbStatus" | awk '/wsrep_cluster_status/ {print $2}') # Primary +rFlowControl=$(echo "$rMariadbStatus" | awk '/wsrep_flow_control_paused\t/ {print $2}') # < 0.1 rFlowControl=$(printf "%.14f" $rFlowControl) # issue #4 -rReady=$(echo "$rMysqlStatus" | awk '/wsrep_ready/ {print $2}') # ON -rConnected=$(echo "$rMysqlStatus" | awk '/wsrep_connected/ {print $2}') # ON -rLocalStateComment=$(echo "$rMysqlStatus" | awk '/wsrep_local_state_comment/ {print $2}') # Synced -rIncommingAddresses=$(echo "$rMysqlStatus" | awk '/wsrep_incoming_addresses/ {print $2}') +rReady=$(echo "$rMariadbStatus" | awk '/wsrep_ready/ {print $2}') # ON +rConnected=$(echo "$rMariadbStatus" | awk '/wsrep_connected/ {print $2}') # ON +rLocalStateComment=$(echo "$rMariadbStatus" | awk '/wsrep_local_state_comment/ {print $2}') # Synced +rIncommingAddresses=$(echo "$rMariadbStatus" | awk '/wsrep_incoming_addresses/ {print $2}') if [ -z "$rFlowControl" ]; then echo "UNKNOWN: wsrep_flow_control_paused is empty"