From dbcfa020448902d42b18770fdc3f85e31d2c0f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Doma=C5=84ski?= Date: Mon, 22 Jun 2026 12:23:33 +0000 Subject: [PATCH] Jun 22, 2026, 2:23 PM --- toolbox/DBAToolBox.ps1 | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/toolbox/DBAToolBox.ps1 b/toolbox/DBAToolBox.ps1 index f029c47..b7f5212 100644 --- a/toolbox/DBAToolBox.ps1 +++ b/toolbox/DBAToolBox.ps1 @@ -157,7 +157,7 @@ function Get-SplunkAPIHosts { # 1. Metoda główna: GET /v2/dimension?query=host try { Write-Log "DEBUG: Rozpoczynam pobieranie wymiarów (Metoda 1: GET /v2/dimension?query=host)..." - $limit = 100 + $limit = 20 $offset = 0 $hasMore = $true @@ -185,10 +185,18 @@ function Get-SplunkAPIHosts { if ($item.key -eq "host" -and -not [string]::IsNullOrWhiteSpace($item.value)) { [void]$hostsSet.Add($item.value.Trim()) } + + # Przerywamy natychmiast, gdy zebraliśmy już 20 unikalnych hostów + if ($hostsSet.Count -ge 20) { + $hasMore = $false + break + } } Write-Log "DEBUG: Pobrano $($results.Count) obiektów wymiarów (offset: $offset). Dotychczas unikalnych hostów: $($hostsSet.Count)" - if ($results.Count -lt $limit) { + if ($hostsSet.Count -ge 20) { + $hasMore = $false + } elseif ($results.Count -lt $limit) { $hasMore = $false } else { $offset += $limit @@ -206,7 +214,7 @@ function Get-SplunkAPIHosts { if ($hostsSet.Count -eq 0) { try { Write-Log "DEBUG: Metoda 1 nie zwróciła hostów. Uruchamiam Metodę zapasową 2 (GET /v2/metrictimeseries)..." - $limit = 100 + $limit = 20 $offset = 0 $hasMore = $true @@ -228,10 +236,18 @@ function Get-SplunkAPIHosts { [void]$hostsSet.Add($val.Trim()) } } + + # Przerywamy natychmiast, gdy zebraliśmy już 20 unikalnych hostów + if ($hostsSet.Count -ge 20) { + $hasMore = $false + break + } } Write-Log "DEBUG: Pobrano $($results.Count) rekordów MTS (offset: $offset). Dotychczas unikalnych hostów: $($hostsSet.Count)" - if ($results.Count -lt $limit) { + if ($hostsSet.Count -ge 20) { + $hasMore = $false + } elseif ($results.Count -lt $limit) { $hasMore = $false } else { $offset += $limit