feat: lifecycle notification_body and aligned host label 1.2.13-SAC

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-31 18:11:20 +10:00
parent cf4e3b2e90
commit 79f5b664b2
3 changed files with 9 additions and 5 deletions
+1 -1
View File
@@ -228,7 +228,7 @@ sac_send_event() {
SAC_DETAILS_JSON="$details_json" \ SAC_DETAILS_JSON="$details_json" \
SAC_AGENT_ID="$(sac_agent_instance_id)" \ SAC_AGENT_ID="$(sac_agent_instance_id)" \
SAC_PRODUCT_VERSION="${SSH_MONITOR_VERSION:-unknown}" \ SAC_PRODUCT_VERSION="${SSH_MONITOR_VERSION:-unknown}" \
SAC_SERVER_DISPLAY_NAME="${SERVER_DISPLAY_NAME:-}" \ SAC_SERVER_DISPLAY_NAME="$(server_display_name_with_ip)" \
SAC_HOST_IPV4="${SERVER_IPV4:-}" \ SAC_HOST_IPV4="${SERVER_IPV4:-}" \
python3 <<'PY' python3 <<'PY'
import json, os, socket, uuid import json, os, socket, uuid
+7 -3
View File
@@ -7,7 +7,7 @@ IFS=$'\n\t'
# ============================================ # ============================================
CONFIG_FILE="/etc/ssh-monitor.conf" 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)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "$SCRIPT_DIR/sac-client.sh" ]; then if [ -f "$SCRIPT_DIR/sac-client.sh" ]; then
@@ -1962,9 +1962,10 @@ send_startup_notification() {
message="${message}⚪ Белый список: ${whitelist_count} IP/подсетей"$'\n' message="${message}⚪ Белый список: ${whitelist_count} IP/подсетей"$'\n'
message="${message}❤️ Heartbeat будет отправляться каждые 12 часов"$'\n' message="${message}❤️ Heartbeat будет отправляться каждые 12 часов"$'\n'
message="${message}📢 Каналы уведомлений (все по списку): $(notify_chain_human)" message="${message}📢 Каналы уведомлений (все по списку): $(notify_chain_human)"
message="$(message_ensure_server_line "$message")"
local lifecycle_details 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" notify_or_sac "agent.lifecycle" "info" "Мониторинг запущен" "ssh-monitor started" "$message" "$lifecycle_details"
write_log "Скрипт мониторинга запущен (белый список: $whitelist_count записей)" write_log "Скрипт мониторинга запущен (белый список: $whitelist_count записей)"
} }
@@ -1977,8 +1978,11 @@ send_shutdown_notification() {
timestamp=$(notification_date '+%d.%m.%Y %H:%M:%S') timestamp=$(notification_date '+%d.%m.%Y %H:%M:%S')
local message=" ⚠️ СКРИПТ МОНИТОРИНГА ОСТАНОВЛЕН "$'\n' local message=" ⚠️ СКРИПТ МОНИТОРИНГА ОСТАНОВЛЕН "$'\n'
message="${message}🕐 Время остановки: ${timestamp}" 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 "Скрипт мониторинга остановлен" write_log "Скрипт мониторинга остановлен"
} }
+1 -1
View File
@@ -1 +1 @@
1.2.12-SAC 1.2.13-SAC