feat: send agent.heartbeat on monitor startup (2.0.34-SAC)
SAC sees host online immediately after restart; periodic heartbeat every 4h unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+19
-10
@@ -90,7 +90,7 @@ $script:SkipLogDetailLimit = 15
|
|||||||
# строки ниже, если правки «мелкие» и вы не хотите менять отображаемую версию в логах).
|
# строки ниже, если правки «мелкие» и вы не хотите менять отображаемую версию в логах).
|
||||||
# Рекомендация: при значимых релизах меняйте и $ScriptVersion, и version.txt одинаково; при только
|
# Рекомендация: при значимых релизах меняйте и $ScriptVersion, и version.txt одинаково; при только
|
||||||
# исправлениях на шаре — достаточно поднять patch в version.txt (например 1.3.0.1).
|
# исправлениях на шаре — достаточно поднять patch в version.txt (например 1.3.0.1).
|
||||||
$ScriptVersion = "2.0.33-SAC"
|
$ScriptVersion = "2.0.34-SAC"
|
||||||
|
|
||||||
# Логи (все под InstallRoot)
|
# Логи (все под InstallRoot)
|
||||||
$LogFile = Join-Path $script:InstallRoot "Logs\login_monitor.log"
|
$LogFile = Join-Path $script:InstallRoot "Logs\login_monitor.log"
|
||||||
@@ -2428,6 +2428,22 @@ function Convert-DailyReportPlainToTelegramHtml {
|
|||||||
return ($out -join "`r`n")
|
return ($out -join "`r`n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Send-RdpMonitorSacHeartbeat {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$Timestamp
|
||||||
|
)
|
||||||
|
Write-TextFileUtf8Bom -Path $HeartbeatFile -Text $Timestamp
|
||||||
|
$script:HeartbeatStaleAlertActive = $false
|
||||||
|
if ($script:SacClientLoaded -and (Get-SacNormalizedMode) -ne 'off') {
|
||||||
|
Send-MonitorNotification -Message '' -EmailSubject 'RDP Login Monitor: heartbeat' `
|
||||||
|
-SacEventType 'agent.heartbeat' -SacSeverity 'info' `
|
||||||
|
-SacTitle 'RDP monitor heartbeat' `
|
||||||
|
-SacSummary "Heartbeat $(Get-MonitorServerLabel) $Timestamp" `
|
||||||
|
-SacDetails @{ host = $env:COMPUTERNAME } | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function Send-Heartbeat {
|
function Send-Heartbeat {
|
||||||
param([switch]$IsStartup = $false)
|
param([switch]$IsStartup = $false)
|
||||||
|
|
||||||
@@ -2540,16 +2556,9 @@ function Send-Heartbeat {
|
|||||||
-SacTitle 'RDP login monitor started' `
|
-SacTitle 'RDP login monitor started' `
|
||||||
-SacSummary "Мониторинг запущен на $(Get-MonitorServerLabelWithIp), версия $ScriptVersion"
|
-SacSummary "Мониторинг запущен на $(Get-MonitorServerLabelWithIp), версия $ScriptVersion"
|
||||||
Write-Log "Отправлено уведомление о запуске скрипта (каналы: $notifyChain)"
|
Write-Log "Отправлено уведомление о запуске скрипта (каналы: $notifyChain)"
|
||||||
|
Send-RdpMonitorSacHeartbeat -Timestamp $timestamp
|
||||||
} else {
|
} else {
|
||||||
Write-TextFileUtf8Bom -Path $HeartbeatFile -Text $timestamp
|
Send-RdpMonitorSacHeartbeat -Timestamp $timestamp
|
||||||
$script:HeartbeatStaleAlertActive = $false
|
|
||||||
if ($script:SacClientLoaded -and (Get-SacNormalizedMode) -ne 'off') {
|
|
||||||
Send-MonitorNotification -Message '' -EmailSubject 'RDP Login Monitor: heartbeat' `
|
|
||||||
-SacEventType 'agent.heartbeat' -SacSeverity 'info' `
|
|
||||||
-SacTitle 'RDP monitor heartbeat' `
|
|
||||||
-SacSummary "Heartbeat $(Get-MonitorServerLabel) $timestamp" `
|
|
||||||
-SacDetails @{ host = $env:COMPUTERNAME } | Out-Null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
2.0.33-SAC
|
2.0.34-SAC
|
||||||
|
|||||||
Reference in New Issue
Block a user