New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Creating Devices with PRTG API

Votes:

0

Your Vote:

Up

Down

As an import from a textfile / database is not possible, i'm looking for another way to create a large number of devices.

Could someone give an example for automating device creation with the prtg api? The device ip-adress and a description (not DNS name) as name of the device should be included.

api automation device prtg

Created on Feb 2, 2018 9:24:59 AM by  Stefan Willing (0) 1



14 Replies

Accepted Answer

Votes:

0

Your Vote:

Up

Down

Check out Lordmilko's PRTG API, it can do what you require (https://github.com/lordmilko/PrtgAPI/wiki/Object-Creation#device-creation-1) and more ;)


Kind regards,
Stephan Linke, Tech Support Team

Created on Feb 2, 2018 11:39:53 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Device creation will be included in the next release of PrtgAPI, due out in the next few weeks

Until then, you can define your own simple AddDevice function to accomplish the same thing

See this issue for more information

Regards,

lordmilko

Created on Feb 4, 2018 11:20:07 PM by  lordmilko (1,932) 2 1



Votes:

0

Your Vote:

Up

Down

Hi lordmilko,

Thanks for sharing - great work, as always :) Let me know if you need any assistance with API calls, etc.


Kind regards,
Stephan Linke, Tech Support Team

Created on Feb 5, 2018 8:13:09 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hello!

I need create device from a browser. I make this: https://192.168.0.10/api/adddevice2.htm?name_=DEV-NAME&host_=192.168.0.100&ipversion_=0&discoverytype_=0&discoveryschedule_=0&id_=79793&username=admin&password=admin

  1. name - Name of the object or channel
  2. host - Hostname or IP address
  3. id - id group, where I want create a device

But I get a answer "Not Found" What I do wrong?

Created on Feb 22, 2019 12:03:43 PM by  Tramp_Sergey (10) 1

Last change on Feb 22, 2019 12:14:52 PM by  Stephan Linke [Paessler Support]



Votes:

1

Your Vote:

Up

Down

Hi Tramp_Sergey,

The "id" property should not have a trailing underscore

Regards, lordmilko

Created on Feb 22, 2019 12:15:32 PM by  lordmilko (1,932) 2 1



Votes:

0

Your Vote:

Up

Down

I have changed it, but the error is still here https://192.168.0.10/api/adddevice2.htm?name_=DEV-NAME&host_=192.168.0.100&ipversion_=0&discoverytype_=0&discoveryschedule_=0&id=79793&username=admin&password=admin

Created on Feb 22, 2019 1:56:58 PM by  Tramp_Sergey (10) 1



Votes:

0

Your Vote:

Up

Down

Why not simply use the PRTGapi as shown here:
https://github.com/lordmilko/PrtgAPI/wiki/Object-Creation#device-creation-1

It makes things so much easier :)

Created on Feb 22, 2019 2:00:40 PM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Unfortunately, I haven`t access to the powershell console for this server, only the web.

Created on Feb 22, 2019 5:45:47 PM by  Tramp_Sergey (10) 1



Votes:

0

Your Vote:

Up

Down

Hi Tramp,

Then I'm afraid this won't work pretty well in this case.

Kind regards,

Erhard

Created on Feb 25, 2019 9:37:29 AM by  Erhard Mikulik [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi!

I have got powershell for PRTG. But, I can't login to the server.

Connect-PRTGServer prtg2 -User ADMIN -PlainTextPassword PASSWORD -Force
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At C:\Program Files\WindowsPowerShell\Modules\PoShPRTG\1.5.0.0\Functions\Connect-PRTGServer.ps1:123 char:17
+ ...     $Hash = Invoke-WebRequest -Uri "$Prefix$server/api/getpasshash.ht ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
 
[2019-03-04 18:18:19] [INFO   ] [CONNECT-PRTGSERVER] Connection to PRTG (https://prtg2) as user ADMIN
Invoke-PRTGSensorTreeRefresh : Cannot validate argument on parameter 'Pass'. The argument is null or empty. Provide an argument that is not null or empty, and then try t
he command again.
At C:\Program Files\WindowsPowerShell\Modules\PoShPRTG\1.5.0.0\Functions\Connect-PRTGServer.ps1:132 char:90
+ ... obal:PRTGServer -User $global:PRTGUser -Pass $global:PRTGPass -Verbos ...
+                                                  ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Invoke-PRTGSensorTreeRefresh], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Invoke-PRTGSensorTreeRefresh

What am I doing wrong?

Created on Mar 4, 2019 4:22:36 PM by  Tramp_Sergey (10) 1

Last change on Mar 4, 2019 4:32:15 PM by  Torsten Lindner [Paessler Support]



Votes:

1

Your Vote:

Up

Down

You are using the PoShPRTG module as opposed to PrtgAPI (which is being discussed in this thread). From the error message, you may want to check the value that is actually being specified for the password is not null or empty.

As neither of these modules are officially supported by Paessler however, you may want to raise an issue on the relevant GitHub repo rather than asking in the Paessler forums

Created on Mar 4, 2019 9:35:38 PM by  lordmilko (1,932) 2 1



Votes:

0

Your Vote:

Up

Down

I have uninstalled PoShPRTG. But I have another errror.

       $ServerName = "prtg2"
       $User = "ADMIN"
       $Pass = "PASSWORD"
       
       add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@

[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

 Connect-PrtgServer $ServerName (New-Credential $User $Pass)
Connect-PrtgServer : The underlying connection was closed: An unexpected error occurred on a send.
At C:\Users\adm.s.prishchepa\Documents\Untitled1.ps1:27 char:8
+        Connect-PrtgServer $ServerName (New-Credential $User $Pass)
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-PrtgServer], WebException
    + FullyQualifiedErrorId : System.Net.WebException,PrtgAPI.PowerShell.Cmdlets.ConnectPrtgServer

Created on Mar 5, 2019 11:51:00 AM by  Tramp_Sergey (10) 1

Last change on Mar 5, 2019 11:57:59 AM by  Torsten Lindner [Paessler Support]



Votes:

1

Your Vote:

Up

Down

To disable SSL validation please specify -IgnoreSSL to Connect-PrtgServer, rather than fiddling with the certificate validation yourself

 Connect-PrtgServer $ServerName (New-Credential $User $Pass) -IgnoreSSL

If your PRTG server doesn't actually run HTTPS however, you need to manually specify "http://" in front of your address, otherwise PrtgAPI will assume HTTPS.

If you've done something to your PRTG server to disable the use of TLS versions prior to 1.2, you may need to instruct PowerShell to use 1.2 only

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

If you still get an error, you can do

$error[0].Exception.InnerException

to potentially get additional details about what the issue was.

Created on Mar 5, 2019 12:03:13 PM by  lordmilko (1,932) 2 1



Votes:

1

Your Vote:

Up

Down

Thank you very much! It work! It's my code for connection

        add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
       
       Connect-PrtgServer $ServerName (New-Credential $User $Pass)

Created on Mar 10, 2019 5:55:15 AM by  Tramp_Sergey (10) 1

Last change on Mar 11, 2019 5:26:57 AM by  Sven Roggenhofer [Paessler Technical Support]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.