<commit_before>#!/bin/bash
# Someone proposed a poor man's replication monitor using Python.
# Having Python or Perl in your server doesn't really qualify as "poor man". 
# In many cases it's a luxury, and thus, here's my shot at the problem, 
# using a Bash shell script.Unlike its Python-based competition, this version also checks that the slave is 
# replicating from the intended master, and that it is not lagging behind.

USERNAME=msandbox
PASSWORD=<PASSWORD>
EXPECTED_MASTER_HOST=127.0.0.1
EXPECTED_MASTER_PORT=27371

SLAVE_HOST=127.0.0.1
SLAVE_PORT=27372

MYSQL="mysql -u $USERNAME -p$PASSWORD "
MASTER="$MYSQL -h $EXPECTED_MASTER_HOST -P $EXPECTED_MASTER_PORT"
SLAVE="$MYSQL -h $SLAVE_HOST -P $SLAVE_PORT"

$MASTER -e 'SHOW MASTER STATUS\G' > mstatus
$SLAVE -e 'SHOW SLAVE STATUS\G' > sstatus

function extract_value {
    FILENAME=$1
    VAR=$2
    grep -w $VAR $FILENAME | awk '{print $2}'
}
<commit_msg>Adjusted the monitor to use a defaults file<commit_after>#!/bin/bash
# Someone proposed a poor man's replication monitor using Python.
# Having Python or Perl in your server doesn't really qualify as "poor man". 
# In many cases it's a luxury, and thus, here's my shot at the problem, 
# using a Bash shell script.Unlike its Python-based competition, this version also checks that the slave is 
# replicating from the intended master, and that it is not lagging behind.

USERNAME=msandbox
PASSWORD=<PASSWORD>
EXPECTED_MASTER_HOST=127.0.0.1
EXPECTED_MASTER_PORT=13454

SLAVE_HOST=127.0.0.1
SLAVE_PORT=13455

tmpcfg=/tmp/my.cfg
echo '[client]' > $tmpcfg
echo "user=$USERNAME" >> $tmpcfg
echo "password=$PASSWORD" >> $tmpcfg
# MYSQL="mysql -u $USERNAME -p$PASSWORD "
MYSQL="mysql --defaults-file=$tmpcfg"
MASTER="$MYSQL -h $EXPECTED_MASTER_HOST -P $EXPECTED_MASTER_PORT"
SLAVE="$MYSQL -h $SLAVE_HOST -P $SLAVE_PORT"

$MASTER -e 'SHOW MASTER STATUS\G' > mstatus
$SLAVE -e 'SHOW SLAVE STATUS\G' > sstatus

function extract_value {
    FILENAME=$1
    VAR=$2
    grep -w $VAR $FILENAME | awk '{print $2}'
}

{'fraction_non_alphanumeric': 0.10758552305404065, 'fraction_numerical': 0.02478929102627665, 'mean_word_length': 4.668539325842697, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3821153', 'n_tokens_mistral': 765, 'n_tokens_neox': 727, 'n_words': 235}