lordmilko / PrtgAPI

C#/PowerShell interface for PRTG Network Monitor
MIT License
305 stars 38 forks source link

PrtgAPI gives error "The remote server returned an error: (503) Server Unavailable" #102

Closed clemensmool closed 5 years ago

clemensmool commented 5 years ago

Hello,

Since a few days we are getting errors from PrtgAPI commands. Connecting to the server works fine and also the command Get-PrtgClient works fine. But commands like get-sensor and get-device resolves in errors (see bellow). Yesterday the command get-prtgstatus works fine but this gives an error since today.

Can you help us to solve this problem?

_PS C:\Windows\system32> Get-PrtgClient
Server     : https://wingenprtg01.ccsilver.local
UserName   : prtgadmin
PassHash   : 
Version    : 
RetryCount : 1
RetryDelay : 3
LogLevel   : Trace, Request

PS C:\Windows\system32> Get-PrtgStatus
WARNING: 'Get-PrtgStatus' timed out: The remote server returned an error: (503) Server Unavailable. Retries remaining:
 1
Get-PrtgStatus : The remote server returned an error: (503) Server Unavailable.
At line:1 char:1
+ Get-PrtgStatus
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-PrtgStatus], WebException
    + FullyQualifiedErrorId : System.Net.WebException,PrtgAPI.PowerShell.Cmdlets.GetPrtgStatus_
lordmilko commented 5 years ago

Hi @clemensmool,

Can you please advise

In addition, if you do

Get-Sensor -Verbose

Copy and paste the URL that is emitted and then do

Invoke-WebRequest <url>

does the Invoke-WebRequest command emit the same error as Get-Sensor does?

clemensmool commented 5 years ago

Thanks for your quick response! When collecting the requested information I noticed that the internet explorer on the prtg server was configured to use a proxy server. When removing this setting everything works fine. Strange enough does connecting to the server works fine when a proxy server is configured but running PrtgAPI commands failes.

lordmilko commented 5 years ago

Thanks @clemensmool,

Good to hear the issue is resolved. Are you able to advise though if you re-enable the proxy on the PRTG Server, confirm commands like Get-Sensor fail again, then do the Invoke-WebRequest test specified above whether you still get the issue or it works fine? This will confirm whether the issue was solely to do with PRTG or whether it was a combination of something the PRTG server and PrtgAPI was doing

clemensmool commented 5 years ago

I was forgotton to mention what a great product PrtgAPI is. It makes managing a PRTG installation a lot easier. For example it is really easy to run remote probes in a self created failover cluster.

clemensmool commented 5 years ago

I just went home, I'll try again tomorrow. Thanks for your quick response.

clemensmool commented 5 years ago

I re-enabled the proxy setting in internet explorer again and when I do a get-device I got the same error message as before: PS C:\Windows\system32> get-device -Status Paused WARNING: 'Get-Device' timed out: The remote server returned an error: (503) Server Unavailable. Retries remaining: 1 get-device : The remote server returned an error: (503) Server Unavailable. At line:1 char:1

I did the test as requested, see the output below:

PS C:\Windows\system32> Get-Sensor -Verbose VERBOSE: Get-Sensor: Synchronously executing request https://wingenprtg01.ccsilver.local/api/table.xml?content=sensors &count=0&username=prtgadmin&passhash=321894000 WARNING: 'Get-Sensor' timed out: The remote server returned an error: (503) Server Unavailable. Retries remaining: 1 Get-Sensor : The remote server returned an error: (503) Server Unavailable. At line:1 char:1

PS C:\Windows\system32> Invoke-WebRequest "https://wingenprtg01.ccsilver.local/api/table.xml?content=sensors &count=0&username=prtgadmin&passhash=321894000" Invoke-WebRequest : The remote server returned an error: (503) Server Unavailable. At line:1 char:1

lordmilko commented 5 years ago

Thanks @clemensmool,

This proves the issue is not specific to PrtgAPI

As you've successfully managed to identify the cause of this issue I will close this issue

Regards, lordmilko