feat: fine-grained ping message
Different PING URLs for various scenarios, enabling success/failure tracking and latency monitoring.
This commit is contained in:
6 files changed
+80
-13
No files matched your search
+34
-9
@@ -127,18 +127,19 @@ function send_mail_content() {
|
||||
########################################
|
||||
# Send health check ping.
|
||||
# Arguments:
|
||||
# None
|
||||
# url
|
||||
# ping name
|
||||
########################################
|
||||
function send_ping() {
|
||||
if [[ -z "${PING_URL}" ]]; then
|
||||
if [[ -z "${1}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
wget "${PING_URL}" -T 15 -t 10 -O /dev/null -q
|
||||
wget "${1}" -T 15 -t 10 -O /dev/null -q
|
||||
if [[ $? != 0 ]]; then
|
||||
color red "ping sending failed"
|
||||
color red "${2} ping sending failed"
|
||||
else
|
||||
color blue "ping send was successfully"
|
||||
color blue "${2} ping send was successfully"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -250,6 +251,7 @@ function init_env() {
|
||||
|
||||
init_env_dir
|
||||
init_env_db
|
||||
init_env_ping
|
||||
init_env_mail
|
||||
|
||||
# CRON
|
||||
@@ -304,10 +306,6 @@ function init_env() {
|
||||
BACKUP_FILE_DATE="$(echo "${BACKUP_FILE_DATE:-"%Y%m%d"}${BACKUP_FILE_DATE_SUFFIX}" | sed 's/[^0-9a-zA-Z%_-]//g')"
|
||||
BACKUP_FILE_DATE_FORMAT="$(echo "${BACKUP_FILE_SUFFIX:-"${BACKUP_FILE_DATE}"}" | sed 's/\///g')"
|
||||
|
||||
# PING_URL
|
||||
get_env PING_URL
|
||||
PING_URL="${PING_URL:-""}"
|
||||
|
||||
# TIMEZONE
|
||||
get_env TIMEZONE
|
||||
local TIMEZONE_MATCHED_COUNT=$(ls "/usr/share/zoneinfo/${TIMEZONE}" 2> /dev/null | wc -l)
|
||||
@@ -349,6 +347,15 @@ function init_env() {
|
||||
if [[ -n "${PING_URL}" ]]; then
|
||||
color yellow "PING_URL: ${PING_URL}"
|
||||
fi
|
||||
if [[ -n "${PING_URL_WHEN_STARTS}" ]]; then
|
||||
color yellow "PING_URL_WHEN_STARTS: ${PING_URL_WHEN_STARTS}"
|
||||
fi
|
||||
if [[ -n "${PING_URL_WHEN_SUCCESS}" ]]; then
|
||||
color yellow "PING_URL_WHEN_SUCCESS: ${PING_URL_WHEN_SUCCESS}"
|
||||
fi
|
||||
if [[ -n "${PING_URL_WHEN_ERROR}" ]]; then
|
||||
color yellow "PING_URL_WHEN_ERROR: ${PING_URL_WHEN_ERROR}"
|
||||
fi
|
||||
color yellow "MAIL_SMTP_ENABLE: ${MAIL_SMTP_ENABLE}"
|
||||
if [[ "${MAIL_SMTP_ENABLE}" == "TRUE" ]]; then
|
||||
color yellow "MAIL_TO: ${MAIL_TO}"
|
||||
@@ -440,6 +447,24 @@ function init_env_db() {
|
||||
fi
|
||||
}
|
||||
|
||||
function init_env_ping() {
|
||||
# PING_URL
|
||||
get_env PING_URL
|
||||
PING_URL="${PING_URL:-""}"
|
||||
|
||||
# PING_URL_WHEN_STARTS
|
||||
get_env PING_URL_WHEN_STARTS
|
||||
PING_URL_WHEN_STARTS="${PING_URL_WHEN_STARTS:-""}"
|
||||
|
||||
# PING_URL_WHEN_SUCCESS
|
||||
get_env PING_URL_WHEN_SUCCESS
|
||||
PING_URL_WHEN_SUCCESS="${PING_URL_WHEN_SUCCESS:-""}"
|
||||
|
||||
# PING_URL_WHEN_ERROR
|
||||
get_env PING_URL_WHEN_ERROR
|
||||
PING_URL_WHEN_ERROR="${PING_URL_WHEN_ERROR:-""}"
|
||||
}
|
||||
|
||||
function init_env_mail() {
|
||||
# MAIL_SMTP_ENABLE
|
||||
# MAIL_TO
|
||||
|
||||
Reference in new issue
Block a user