feat: lifecycle notification_body and aligned host label 1.2.13-SAC
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+7
-3
@@ -7,7 +7,7 @@ IFS=$'\n\t'
|
||||
# ============================================
|
||||
|
||||
CONFIG_FILE="/etc/ssh-monitor.conf"
|
||||
SSH_MONITOR_VERSION="1.2.12-SAC"
|
||||
SSH_MONITOR_VERSION="1.2.13-SAC"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
if [ -f "$SCRIPT_DIR/sac-client.sh" ]; then
|
||||
@@ -1962,9 +1962,10 @@ send_startup_notification() {
|
||||
message="${message}⚪ Белый список: ${whitelist_count} IP/подсетей"$'\n'
|
||||
message="${message}❤️ Heartbeat будет отправляться каждые 12 часов"$'\n'
|
||||
message="${message}📢 Каналы уведомлений (все по списку): $(notify_chain_human)"
|
||||
message="$(message_ensure_server_line "$message")"
|
||||
|
||||
local lifecycle_details
|
||||
lifecycle_details='{"lifecycle":"started","trigger":"boot"}'
|
||||
lifecycle_details="$(NOTIFICATION_BODY="$message" python3 -c 'import json, os; print(json.dumps({"lifecycle":"started","trigger":"boot","notification_body":os.environ["NOTIFICATION_BODY"]}, ensure_ascii=False))')"
|
||||
notify_or_sac "agent.lifecycle" "info" "Мониторинг запущен" "ssh-monitor started" "$message" "$lifecycle_details"
|
||||
write_log "Скрипт мониторинга запущен (белый список: $whitelist_count записей)"
|
||||
}
|
||||
@@ -1977,8 +1978,11 @@ send_shutdown_notification() {
|
||||
timestamp=$(notification_date '+%d.%m.%Y %H:%M:%S')
|
||||
local message=" ⚠️ СКРИПТ МОНИТОРИНГА ОСТАНОВЛЕН "$'\n'
|
||||
message="${message}🕐 Время остановки: ${timestamp}"
|
||||
message="$(message_ensure_server_line "$message")"
|
||||
|
||||
notify_or_sac "agent.lifecycle" "info" "Мониторинг остановлен" "ssh-monitor stopped" "$message" '{"lifecycle":"stopped","trigger":"shutdown"}'
|
||||
local lifecycle_details
|
||||
lifecycle_details="$(NOTIFICATION_BODY="$message" python3 -c 'import json, os; print(json.dumps({"lifecycle":"stopped","trigger":"shutdown","notification_body":os.environ["NOTIFICATION_BODY"]}, ensure_ascii=False))')"
|
||||
notify_or_sac "agent.lifecycle" "info" "Мониторинг остановлен" "ssh-monitor stopped" "$message" "$lifecycle_details"
|
||||
write_log "Скрипт мониторинга остановлен"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user