RetryCount does not seem to work
What's going on?
Hello,
we have a quite large PRTG Installation and sometimes it takes a long time that the prtg api does it thing ;) No i tried to set RetryCount and RetryDelay higher but it does not seem to work:
I set RetryCount and RetryDelay to 20:
Connect-PrtgServer "https://$($PRTGServer):$($PRTGPort)" (New-Credential $PRTGUser $PRTGPassHash) -PassHash -RetryCount 20 -RetryDelay 20
And now i expected that i see something like Retries remaining 20 instead of 4 ?
Am i just doing it wrong?
thank you, best regards xasz
Due Dilligance
- [X] It wasn't covered by the wiki, I swear!
- [X] I have tried doing some basic research on this issue but haven't been able to come up with anything. Please help!
I'm unable to reproduce this issue. Are you able to confirm what version of PrtgAPI you're running?
Has the above screenshot been manipulated, or is it the output of a script? (as opposed to raw commands being typed in a PowerShell prompt)
Can you also please provide the output of Get-PrtgClient -Diagnostic
The screenshot is not manipulated in any form. It was just a half output of the get-prtgclient.
Sure, here we go with some additional informations:
Get-PrtgClient -Diagnostic
PSVersion : 5.1.17763.2803
PSEdition : Desktop
OS : Microsoft Windows Server 2019 Standard
PrtgAPIVersion : 0.9.17
Culture : de-DE
CLRVersion : .NET Framework 4.7.2 (461814)
PrtgVersion : 22.2.76.1705
PrtgLanguage : german.lng
The "call" of the actual Add-Sensor/Add-Device Sensor is quite complex and i just can't copy paste it in three lines.
This is my Setup:
Script: Update-PRTGDevices.ps1
Import-Module prtghelper.psm1 -force # This is a custom helper module for us internal to share some methods between scripts
Connect-PrtgServer "https://$($PRTGServer):$($PRTGPort)" (New-Credential $PRTGUser $PRTGPassHash) -PassHash -RetryCount 50 -RetryDelay 50
# Gather some devices from the crm
foreach($erpdevice in $erpdevices){
$myDevice = Set-PRTGDevice -Parent $someParentGroup -ERPDevice $erpdevice
# now we add / replace some sensors with the "same" method as on the the device.
}
Custom Module: prtghelper.psm1
function Set-PRTGDevice{
param($Parent, $ERPDevice)
$device = $Parent | Get-Device -Name $DeviceName
# Sometimes this just return nothing even if there is a correct device
if(($device | Measure-Object).Count -gt 0){
if(($device | Measure-Object).Count -gt 1){
throw "$DeviceName in $($Parent.Name) not unique"
}
$device | Set-ObjectProperty Host $Hostname
}else{
$device = $Parent | Add-Device $DeviceName $($Hostname)
# THIS will "fail" and take aged on adding multiple devices. and i return a wrong result
}
return $device
}