What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Filter sensors

Votes:

0

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 ?

api group libraries prtg sensors

Created on Feb 17, 2022 10:34:41 AM

Last change on Feb 17, 2022 3:06:28 PM by  Felix Wiesneth [Paessler Support]



1 Reply

Votes:

0

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.

Created on Feb 18, 2022 9:25:52 AM by  Florian Lesage [Paessler Support]




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.