feat: adiciona informacoes de reinicio e melhora SLA global
All checks were successful
All checks were successful
- Agente Rust: captura LastBootTime, uptime e contagem de boots - Backend: extrai campos do extended (bootInfo, discos, RAM, etc) antes de salvar - Frontend /devices: exibe secao de ultimo reinicio - SLA global: adiciona campos de modo, threshold de alerta e status de pausa - Corrige acento em "destinatario" -> "destinatario" em automations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d32b94c22d
commit
f39bd46c2b
7 changed files with 338 additions and 19 deletions
|
|
@ -1099,6 +1099,41 @@ fn collect_windows_extended() -> serde_json::Value {
|
|||
}
|
||||
"#).unwrap_or_else(|| json!({}));
|
||||
|
||||
// Último reinício e contagem de boots
|
||||
let boot_info = ps(r#"
|
||||
$os = Get-CimInstance Win32_OperatingSystem | Select-Object LastBootUpTime
|
||||
$lastBoot = $os.LastBootUpTime
|
||||
|
||||
# Calcula uptime
|
||||
$uptime = if ($lastBoot) { (New-TimeSpan -Start $lastBoot -End (Get-Date)).TotalSeconds } else { 0 }
|
||||
|
||||
# Conta eventos de boot (ID 6005) - últimos 30 dias para performance
|
||||
$startDate = (Get-Date).AddDays(-30)
|
||||
$bootEvents = @()
|
||||
$bootCount = 0
|
||||
try {
|
||||
$events = Get-WinEvent -FilterHashtable @{
|
||||
LogName = 'System'
|
||||
ID = 6005
|
||||
StartTime = $startDate
|
||||
} -MaxEvents 50 -ErrorAction SilentlyContinue
|
||||
$bootCount = @($events).Count
|
||||
$bootEvents = @($events | Select-Object -First 10 | ForEach-Object {
|
||||
@{
|
||||
TimeCreated = $_.TimeCreated.ToString('o')
|
||||
Computer = $_.MachineName
|
||||
}
|
||||
})
|
||||
} catch {}
|
||||
|
||||
[PSCustomObject]@{
|
||||
LastBootTime = if ($lastBoot) { $lastBoot.ToString('o') } else { $null }
|
||||
UptimeSeconds = [math]::Round($uptime)
|
||||
BootCountLast30Days = $bootCount
|
||||
RecentBoots = $bootEvents
|
||||
}
|
||||
"#).unwrap_or_else(|| json!({ "LastBootTime": null, "UptimeSeconds": 0, "BootCountLast30Days": 0, "RecentBoots": [] }));
|
||||
|
||||
json!({
|
||||
"windows": {
|
||||
"software": software,
|
||||
|
|
@ -1125,6 +1160,7 @@ fn collect_windows_extended() -> serde_json::Value {
|
|||
"networkAdapters": network_adapters,
|
||||
"monitors": monitors,
|
||||
"chassis": power_supply,
|
||||
"bootInfo": boot_info,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue