Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
monodb-mysql/pgsql-health.sh: Add Direct Message alarm support
Browse files Browse the repository at this point in the history
  • Loading branch information
kreatoo committed Apr 16, 2024
1 parent 617564a commit fc60c8f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .bin/monodb-mysql-health.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
ALARM_WEBHOOK_URL=example.com
ALARM_BOT_API_URL=https://example.com
[email protected]
ALARM_BOT_API_KEY=testkey
[email protected]
IDENTIFIER="test"
SEND_ALARM=1
SEND_DM_ALARM=1
PROCESS_LIMIT=50
IS_CLUSTER=0
CLUSTER_SIZE=3
CLUSTER_SIZE=3
5 changes: 5 additions & 0 deletions .bin/monodb-pgsql-health.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
ALARM_WEBHOOK_URL=example.com
ALARM_BOT_API_URL=https://example.com
[email protected]
ALARM_BOT_API_KEY=testkey
[email protected]
IDENTIFIER="test"
PATRONI_API="http://localhost:8008/cluster"
SEND_ALARM=1
SEND_DM_ALARM=1
14 changes: 11 additions & 3 deletions monodb/monodb-mysql-health.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@ function print_colour() {
}

function alarm() {
if [ "$SEND_ALARM" == "1" ]; then
curl -fsSL -X POST -H "Content-Type: application/json" -d "{\"text\": \"$1\"}" "$ALARM_WEBHOOK_URL" 1>/dev/null
fi
if [ "$SEND_ALARM" == "1" ]; then
curl -fsSL -X POST -H "Content-Type: application/json" -d "{\"text\": \"$1\"}" "$ALARM_WEBHOOK_URL" 1>/dev/null
fi

if [ "$SEND_DM_ALARM" = "1" ] && [ -n "$ALARM_BOT_API_KEY" ] && [ -n "$ALARM_BOT_EMAIL" ] && [ -n "$ALARM_BOT_API_URL" ] && [ -n "$ALARM_BOT_USER_EMAIL" ]; then
curl -s -X POST "$ALARM_BOT_API_URL"/api/v1/messages \
-u "$ALARM_BOT_EMAIL:$ALARM_BOT_API_KEY" \
--data-urlencode type=direct \
--data-urlencode "to=$ALARM_BOT_USER_EMAIL" \
--data-urlencode "content=$1" 1> /dev/null
fi
}

function alarm_check_down() {
Expand Down
14 changes: 11 additions & 3 deletions monodb/monodb-pgsql-health.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@ function print_colour() {
}

function alarm() {
if [ "$SEND_ALARM" == "1" ]; then
curl -fsSL -X POST -H "Content-Type: application/json" -d "{\"text\": \"$1\"}" "$ALARM_WEBHOOK_URL" 1>/dev/null
fi
if [ "$SEND_ALARM" == "1" ]; then
curl -fsSL -X POST -H "Content-Type: application/json" -d "{\"text\": \"$1\"}" "$ALARM_WEBHOOK_URL" 1>/dev/null
fi

if [ "$SEND_DM_ALARM" = "1" ] && [ -n "$ALARM_BOT_API_KEY" ] && [ -n "$ALARM_BOT_EMAIL" ] && [ -n "$ALARM_BOT_API_URL" ] && [ -n "$ALARM_BOT_USER_EMAIL" ]; then
curl -s -X POST "$ALARM_BOT_API_URL"/api/v1/messages \
-u "$ALARM_BOT_EMAIL:$ALARM_BOT_API_KEY" \
--data-urlencode type=direct \
--data-urlencode "to=$ALARM_BOT_USER_EMAIL" \
--data-urlencode "content=$1" 1> /dev/null
fi
}

function alarm_check_down() {
Expand Down

0 comments on commit fc60c8f

Please sign in to comment.