Skip to content

Commit

Permalink
monodb: mysql-health/pgsql-health: use REDMINE_IDENTIFIER on redmine …
Browse files Browse the repository at this point in the history
…parts instead of IDENTIFIER
  • Loading branch information
kreatoo committed Sep 10, 2024
1 parent c5f8771 commit 270f92e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
12 changes: 7 additions & 5 deletions scripts/monodb/mysql-health.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ function check_cluster_status() {
echo_status "Cluster Status:"
cluster_status=$(mysql -sNe "SHOW STATUS WHERE Variable_name = 'wsrep_cluster_size';")
no_cluster=$(echo "$cluster_status" | awk '{print $2}')


IDENTIFIER_REDMINE=$(echo "$IDENTIFIER" | cut -d'-' -f1-2)

if [[ ! -f /tmp/mono/mysql-cluster-size-redmine.log ]]; then
if monokit redmine issue exists --subject "Cluster size is $no_cluster at $IDENTIFIER" --date "$(date +"%Y-%m-%d")" > "$TMP_PATH_SCRIPT"/pgsql-cluster-size-redmine.log; then
if monokit redmine issue exists --subject "Cluster size is $no_cluster at $IDENTIFIER_REDMINE" --date "$(date +"%Y-%m-%d")" > "$TMP_PATH_SCRIPT"/pgsql-cluster-size-redmine.log; then
ISSUE_ID=$(cat "$TMP_PATH_SCRIPT"/mysql-cluster-size-redmine.log)
fi

Expand All @@ -131,20 +133,20 @@ function check_cluster_status() {

if [ "$no_cluster" -eq "$CLUSTER_SIZE" ]; then
alarm_check_up "cluster_size" "Cluster size is accurate: $no_cluster/$CLUSTER_SIZE"
monokit redmine issue close --service "mysql-cluster-size" --message "MySQL cluster size is $no_cluster at $IDENTIFIER"
monokit redmine issue close --service "mysql-cluster-size" --message "MySQL cluster size is $no_cluster at $IDENTIFIER_REDMINE"
print_colour "Cluster size" "$no_cluster/$CLUSTER_SIZE"
elif [ -z "$no_cluster" ]; then
alarm_check_down "cluster_size" "Couldn't get cluster size: $no_cluster/$CLUSTER_SIZE"
monokit redmine issue update --service "mysql-cluster-size" --message "Couldn't get cluster size with command: \"mysql -sNe \"SHOW STATUS WHERE Variable_name = 'wsrep_cluster_size';\"\""
print_colour "Cluster size" "Couln't get" "error"
else
alarm_check_down "cluster_size" "Cluster size is not accurate: $no_cluster/$CLUSTER_SIZE"
monokit redmine issue update --service "mysql-cluster-size" --message "MySQL cluster size is $no_cluster at $IDENTIFIER"
monokit redmine issue update --service "mysql-cluster-size" --message "MySQL cluster size is $no_cluster at $IDENTIFIER_REDMINE"
print_colour "Cluster size" "$no_cluster/$CLUSTER_SIZE" "error"
fi

if [[ "$no_cluster" -eq 1 ]] || [[ "$no_cluster" -gt $CLUSTER_SIZE ]]; then
monokit redmine issue create --service "mysql-cluster-size" --subject "Cluster size is $no_cluster at $IDENTIFIER" --message "MySQL cluster size is $no_cluster at $IDENTIFIER"
monokit redmine issue create --service "mysql-cluster-size" --subject "Cluster size is $no_cluster at $IDENTIFIER_REDMINE" --message "MySQL cluster size is $no_cluster at $IDENTIFIER"
fi
}

Expand Down
13 changes: 9 additions & 4 deletions scripts/monodb/pgsql-health.sh
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,13 @@ function cluster_status() {
i=$((i + 1))
done

# should result in
# IDENTIFIER=test-test2-test3
# IDENTIFIER_REDMINE=test-test2
IDENTIFIER_REDMINE=$(echo "$IDENTIFIER" | cut -d'-' -f1-2)

if [[ ! -f /tmp/mono/pgsql-cluster-size-redmine.log ]]; then
if monokit redmine issue exists --subject "Cluster size is $((i - j)) at $IDENTIFIER" --date "$(date +"%Y-%m-%d")" > "$TMP_PATH_SCRIPT"/pgsql-cluster-size-redmine.log; then
if monokit redmine issue exists --subject "PgSQL Cluster size is $((i - j)) at $IDENTIFIER_REDMINE" --date "$(date +"%Y-%m-%d")" > "$TMP_PATH_SCRIPT"/pgsql-cluster-size-redmine.log; then
ISSUE_ID=$(cat "$TMP_PATH_SCRIPT"/pgsql-cluster-size-redmine.log)
fi

Expand All @@ -238,11 +243,11 @@ function cluster_status() {
fi

if [[ $((i - j)) -eq 1 ]]; then
monokit redmine issue create --service "pgsql-cluster-size" --subject "Cluster size is $((i - j)) at $IDENTIFIER" --message "Patroni cluster size is $((i - j)) at $IDENTIFIER"
monokit redmine issue create --service "pgsql-cluster-size" --subject "PgSQL Cluster size is $((i - j)) at $IDENTIFIER_REDMINE" --message "Patroni cluster size is $((i - j)) at $IDENTIFIER_REDMINE"
elif [[ $j -eq 0 ]]; then
monokit redmine issue close --service "pgsql-cluster-size" --message "Patroni cluster size is $((i - j)) at $IDENTIFIER"
monokit redmine issue close --service "pgsql-cluster-size" --message "Patroni cluster size is $((i - j)) at $IDENTIFIER_REDMINE"
else
monokit redmine issue update --service "pgsql-cluster-size" --message "Patroni cluster size is $((i - j)) at $IDENTIFIER"
monokit redmine issue update --service "pgsql-cluster-size" --message "Patroni cluster size is $((i - j)) at $IDENTIFIER_REDMINE"
fi
}

Expand Down

0 comments on commit 270f92e

Please sign in to comment.