Hello,
I have several networks to monitor.
I would like to find a way to filter each network and call it with PRTG API.
-> One call API to get all devices/sensors of one network
What I've tried:
- Grouping, but I can't group sensors in the same group (You cannot move "fixed" object).
- Libraries, it's much better but there is no API call for it.
Do you have any advice ?
Article Comments
Hello Romain,
Thank you for your message.
Regarding what you would like to achieve, you could use the API of PRTG to get and filter the name and or address of the devices to keep only those you desire.
To do so, you can use the PowerShell module PRTGAPI (from third party) to get the devices (with the cmdlet Get-Device) and then apply a filter to the command with Where-Object such as :
Get-Device | Where {$_.Host -like "10.0.*"}
Finally, to get all sensors from those devices you need to use a foreach look in which you execute the command below:
Get-Device -Id <DeviceID> | Get-Sensor
Here is a template which might help. Please note that we do not provide official support for it, the latter is provided as is and any modification and usage are up to you.
param(
[string] $hostname = "", # Address of your PRTG server
[string] $username = "", # The username of your PRTG account
[string] $passhash = "" # The passhash of your user account (from Setup > Account Settings > My Account)
)
try {
if(!(Get-PrtgClient)){
Connect-PrtgServer $hostname (New-Credential $username $passhash) -PassHash -IgnoreSSL
}
# Your code goes here
} catch {
write-host "$($_.exception.message) At line : $($_.InvocationInfo.ScriptLineNumber)" -ForegroundColor Red
}
If you have questions, do not hesitate.
Regards.
Feb, 2022 - Permalink
Hello Romain,
Thank you for your message.
Regarding what you would like to achieve, you could use the API of PRTG to get and filter the name and or address of the devices to keep only those you desire.
To do so, you can use the PowerShell module PRTGAPI (from third party) to get the devices (with the cmdlet Get-Device) and then apply a filter to the command with Where-Object such as :
Finally, to get all sensors from those devices you need to use a foreach look in which you execute the command below:
Here is a template which might help. Please note that we do not provide official support for it, the latter is provided as is and any modification and usage are up to you.
If you have questions, do not hesitate.
Regards.
Feb, 2022 - Permalink