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.
Article Comments
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
Feb, 2018 - Permalink
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
Feb, 2018 - Permalink
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
- name - Name of the object or channel
- host - Hostname or IP address
- id - id group, where I want create a device
But I get a answer "Not Found" What I do wrong?
Feb, 2019 - Permalink
Hi Tramp_Sergey,
The "id" property should not have a trailing underscore
Regards, lordmilko
Feb, 2019 - Permalink
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
Feb, 2019 - Permalink
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 :)
Feb, 2019 - Permalink
Unfortunately, I haven`t access to the powershell console for this server, only the web.
Feb, 2019 - Permalink
Hi Tramp,
Then I'm afraid this won't work pretty well in this case.
Kind regards,
Erhard
Feb, 2019 - Permalink
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?
Mar, 2019 - Permalink
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
Mar, 2019 - Permalink
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
Mar, 2019 - Permalink
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.
Mar, 2019 - Permalink
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)
Mar, 2019 - Permalink
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
Feb, 2018 - Permalink