diff --git a/release_version.txt b/release_version.txt index 940ac09..267577d 100644 --- a/release_version.txt +++ b/release_version.txt @@ -1 +1 @@ -0.3.9 +0.4.1 diff --git a/scripts/healthcheck/storage_health_check.sh b/scripts/healthcheck/storage_health_check.sh index 336b09e..390966a 100755 --- a/scripts/healthcheck/storage_health_check.sh +++ b/scripts/healthcheck/storage_health_check.sh @@ -7,18 +7,9 @@ RootDir="${HOME}/prod" export PYTHONPATH=${RootDir} -# Temporary -MmStatusSender= -MmStatusSender="${MmStatusSender} ${HOME}/.pyenv/python3.10-venv/bin/python3" -MmStatusSender="${MmStatusSender} ${RootDir}/cvttpy/apps/utils/mmost_sender.py" -MmStatusSender="${MmStatusSender} --channel=Status-CVTT" -MmStatusSender="${MmStatusSender} --log_level=ERROR" - -MmAlertSender= -MmAlertSender="${MmAlertSender} ${HOME}/.pyenv/python3.10-venv/bin/python3" -MmAlertSender="${MmAlertSender} ${RootDir}/cvttpy/apps/utils/mmost_sender.py" -MmAlertSender="${MmAlertSender} --channel=Alerts-CVTT" -MmAlertSender="${MmAlertSender} --log_level=ERROR" +StatusChannel=Status-CVTT +AlertChannel=Alerts-CVTT +Sender=${RootDir}/ops/utils/send_mmost.sh Hosts= Hosts="${Hosts} cloud11.cvtt.vpn" @@ -84,14 +75,14 @@ function storage_check() { Measurements=() tmpfile=$(mktemp) storage_check > ${tmpfile} -cat ${tmpfile} | ${MmStatusSender} +cat ${tmpfile} | ${Sender} ${StatusChannel} tmpfile=$(mktemp) space_alert > ${tmpfile} cat ${tmpfile} if [ -s ${tmpfile} ] then - (echo "### :card_file_box: STORAGE ALERTS" && cat ${tmpfile}) | ${MmAlertSender} + (echo "### :card_file_box: STORAGE ALERTS" && cat ${tmpfile}) | ${Sender} ${AlertChannel} else echo File ${tmpfile} is empty fi diff --git a/utils/send_mmost.sh b/utils/send_mmost.sh index 5a5eda4..432638b 100755 --- a/utils/send_mmost.sh +++ b/utils/send_mmost.sh @@ -23,20 +23,24 @@ Cmd="${Cmd} | jq -r '.id'" channel_id=$(eval ${Cmd}) -input=$(cat) +input="$(cat)" + body="{" -body="${body}\\\"channel_id\\\":\\\"${channel_id}\\\"" -body="${body}, \\\"message\\\":\\\"${input}\\\"" +body="${body}\"channel_id\":\"${channel_id}\"" +body="${body}, \"message\":\"${input}\"" body="${body}}" +# replace new line with literal \n +body=$(echo "${body}" |awk '{printf "%s\\n", $0}') + post_url="${url}/api/v4/posts" Cmd="curl -s" -Cmd="${Cmd} -X POST" -Cmd="${Cmd} -H \"Content-Type: Application/JSON\"" -Cmd="${Cmd} -H \"Authorization: Bearer ${bearer}\"" -Cmd="${Cmd} --data \"${body}\"" +Cmd="${Cmd} --request POST" +Cmd="${Cmd} --header \"Content-Type: Application/JSON\"" +Cmd="${Cmd} --header \"Authorization: Bearer ${bearer}\"" +Cmd="${Cmd} --data @-" Cmd="${Cmd} ${post_url}" -eval ${Cmd} > /dev/null +(echo "${body}" | eval ${Cmd}) > /dev/null