<commit_before>#!/bin/bash

###################################################
# Centreon                                 Jan 2020 
#
# Checks the replication state
#
###################################################

. /usr/share/centreon-ha/lib/mysql-functions.sh
. /etc/centreon-ha/mysql-resources.sh


append_error_msg()
{
	eval $1=\"\$$1\$$3\$2\"
	eval $3=\"\\n\ \ \ \ \"
}

display_result_one()
{
	echo -n "$2 ["
	if [ "$1" -eq 0 ] ; then
		echo -en "\033[1;32mOK\033[m"
	elif [ "$1" -eq -1 ] ; then
		echo -en "\033[33mWARNING\033[m"
	elif [ "$1" -eq -2 ] ; then
		echo -en "SKIP"
	else
		echo -en "\033[31mKO\033[m"
	fi
	echo "]"
	
	if [ -n "$3" ] ; then
		echo "Error reports:"
		echo -e "    $3"
	fi
}

display_result()
{
	display_result_one $connexion_status_server1 "Connection Status '$DBHOSTNAMEMASTER'" "$report_connexion1"
	display_result_one $connexion_status_server2 "Connection Status '$DBHOSTNAMESLAVE'" "$report_connexion2"
	display_result_one $slave_status "Slave Thread Status" "$slave_status_error"
	display_result_one $position_status "Position Status" "$position_status_error"
}

usage()
{
echo
echo "Use : $0"
echo
}

cmd_line()
{
	:<commit_msg>PS-48 (Enh) Add actual Master/Slave information in output (#66)<commit_after>#!/bin/bash

###################################################
# Centreon                                Sept 2022
#
# Checks the replication state
#
###################################################

. /usr/share/centreon-ha/lib/mysql-functions.sh
. /etc/centreon-ha/mysql-resources.sh


append_error_msg()
{
	eval $1=\"\$$1\$$3\$2\"
	eval $3=\"\\n\ \ \ \ \"
}

display_result_one()
{
	echo -n "$2 ["
	if [ "$1" -eq 0 ] ; then
		echo -en "\033[1;32mOK\033[m"
	elif [ "$1" -eq -1 ] ; then
		echo -en "\033[33mWARNING\033[m"
	elif [ "$1" -eq -2 ] ; then
		echo -en "SKIP"
	else
		echo -en "\033[31mKO\033[m"
	fi
	echo "]"
	
	if [ -n "$3" ] ; then
		echo "Error reports:"
		echo -e "    $3"
	fi
}

display_result()
{
	if [[ "$slave_address" == "$DBHOSTNAMEMASTER" ]] ; then
		display_result_one "$connexion_status_server2" "Connection MASTER Status '$DBHOSTNAMESLAVE'" "$report_connexion2"
		display_result_one "$connexion_status_server1" "Connection SLAVE Status '$DBHOSTNAMEMASTER'" "$report_connexion1"
	elif [[ "$slave_address" == "$DBHOSTNAMESLAVE" ]] ; then
		display_result_one "$connexion_status_server1" "Connection MASTER Status '$DBHOSTNAMEMASTER'" "$report_connexion1"
		display_result_one "$connexion_status_server2" "Connection SLAVE Status '$DBHOSTNAMESLAVE'" "$report_connexion2"
	else
		display_result_one "$connexion_status_server1" "Connection SLAVE Status '$DBHOSTNAMEMASTER'" "$report_connexion1"
		display_result_one "$connexion_status_server2" "Connection SLAVE Status '$DBHOSTNAMESLAVE'" "$report_connexion2"
	fi
	display_result_one $slave_status "Slave Thread Status" "$slave_status_error"
	display_result_one $position_status "Position Status" "$position_status_error"
}

usage()
{
echo
echo "Use : $0"
echo
}

cmd_line()
{
	:
{'fraction_non_alphanumeric': 0.2125748502994012, 'fraction_numerical': 0.03592814371257485, 'mean_word_length': 4.2478184991273995, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5200357', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1103, 'n_words': 230}