Jun 22, 2026, 2:23 PM
This commit is contained in:
+20
-4
@@ -157,7 +157,7 @@ function Get-SplunkAPIHosts {
|
|||||||
# 1. Metoda główna: GET /v2/dimension?query=host
|
# 1. Metoda główna: GET /v2/dimension?query=host
|
||||||
try {
|
try {
|
||||||
Write-Log "DEBUG: Rozpoczynam pobieranie wymiarów (Metoda 1: GET /v2/dimension?query=host)..."
|
Write-Log "DEBUG: Rozpoczynam pobieranie wymiarów (Metoda 1: GET /v2/dimension?query=host)..."
|
||||||
$limit = 100
|
$limit = 20
|
||||||
$offset = 0
|
$offset = 0
|
||||||
$hasMore = $true
|
$hasMore = $true
|
||||||
|
|
||||||
@@ -185,10 +185,18 @@ function Get-SplunkAPIHosts {
|
|||||||
if ($item.key -eq "host" -and -not [string]::IsNullOrWhiteSpace($item.value)) {
|
if ($item.key -eq "host" -and -not [string]::IsNullOrWhiteSpace($item.value)) {
|
||||||
[void]$hostsSet.Add($item.value.Trim())
|
[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)"
|
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
|
$hasMore = $false
|
||||||
} else {
|
} else {
|
||||||
$offset += $limit
|
$offset += $limit
|
||||||
@@ -206,7 +214,7 @@ function Get-SplunkAPIHosts {
|
|||||||
if ($hostsSet.Count -eq 0) {
|
if ($hostsSet.Count -eq 0) {
|
||||||
try {
|
try {
|
||||||
Write-Log "DEBUG: Metoda 1 nie zwróciła hostów. Uruchamiam Metodę zapasową 2 (GET /v2/metrictimeseries)..."
|
Write-Log "DEBUG: Metoda 1 nie zwróciła hostów. Uruchamiam Metodę zapasową 2 (GET /v2/metrictimeseries)..."
|
||||||
$limit = 100
|
$limit = 20
|
||||||
$offset = 0
|
$offset = 0
|
||||||
$hasMore = $true
|
$hasMore = $true
|
||||||
|
|
||||||
@@ -228,10 +236,18 @@ function Get-SplunkAPIHosts {
|
|||||||
[void]$hostsSet.Add($val.Trim())
|
[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)"
|
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
|
$hasMore = $false
|
||||||
} else {
|
} else {
|
||||||
$offset += $limit
|
$offset += $limit
|
||||||
|
|||||||
Reference in New Issue
Block a user