param( [int]$DurationSeconds = 90, [string]$Output = "evidence/lab3/pg-stat-activity.log" ) $end = (Get-Date).AddSeconds($DurationSeconds) "=== pg_stat_activity collection started at $(Get-Date -Format o) ===" | Out-File $Output while ((Get-Date) -lt $end) { "--- $(Get-Date -Format o) ---" | Add-Content $Output docker compose exec -T db psql -U messenger -d messenger -c "SELECT state, wait_event_type, wait_event, count(*) FROM pg_stat_activity WHERE datname='messenger' GROUP BY 1,2,3 ORDER BY 4 DESC;" 2>&1 | Add-Content $Output Start-Sleep -Seconds 5 } "=== collection finished at $(Get-Date -Format o) ===" | Add-Content $Output