Skip to content
lordmilko edited this page Oct 17, 2017 · 21 revisions

C#

Probes can be retrieved from a PRTG Server via the GetProbes method

var probes = client.GetProbes();

If you wish to filter for probes that meet certain search criteria you can specify a Property to filter on using one of several overloads

//Get probes whose name match "Contoso (Head Office)"
var groups = client.GetGroups(Property.Name, "Contoso (Head Office)");
//Get probes containing more than 20 devices
var groups = client.GetGroups(Property.TotalDevices, FilterOperator.GreaterThan, 20);

Filters are implemented internally via the SearchFilter class. One or more SearchFilter objects can be specified to filter on multiple properties.

//Get all probes with more than 10 sensors under probes whose name contains "office"
var filters = new[]
{
    new SearchFilter(Property.TotalSensors, FilterOperator.GreaterThan, 10),
    new SearchFilter(Property.Name, FilterOperator.Contains, "office")
};

var probes = client.GetProbes(filters);

GetProbes can be used in conjunction with other methods in order to chain results together.

//Get all sensors for all probes whose name contains "office"
var sensors = client.GetProbes(Property.Name, FilterOperator.Contains, "infrastructure").SelectMany(
    probe => client.GetSensors(Property.Probe, probe.Name)
);

PowerShell

Probes can be retrieved with PowerShell via the Get-Probe cmdlet. (Note: for complete instructions on using Get-Probe, please see Get-Help Get-Probe)

C:\> Get-Probe

Name                Id      Status      Devices    Groups    Up       Down  Down   Warning  Paused
                                                             Sensors        (Ack)
----                --      ------      -------    ------    -------  ----  -----  -------  ------
Local Probe         1       Up          30         3         11       20    10     2        100
Contoso (New York)  2001    Up          20         2         30       2     3      1        0

PrtgAPI automatically formats Probes objects in a table, displaying the most relevant properties. To view all properties of probes, pipe your probesto Format-List

Get all probesnamed "Local Probe" (case insensitive)

C:\> Get-Group "local probe"

Name                Id      Status      Devices    Groups    Up       Down  Down   Warning  Paused
                                                             Sensors        (Ack)
----                --      ------      -------    ------    -------  ----  -----  -------  ------
Local Probe         1       Up          30         3         11       20    10     2        100

Wildcards can also be used

Get-Probe *local*,*conto*

Get-Probe can filter on a number of properties, including Id, Tags

C:\> Get-Probe -Id 0,2001

Name                Id      Status      Devices    Groups    Up       Down  Down   Warning  Paused
                                                             Sensors        (Ack)
----                --      ------      -------    ------    -------  ----  -----  -------  ------
Local Probe         1       Up          30         3         11       20    10     2        100
Contoso (New York)  2001    Up          20         2         30       2     3      1        0
# Get all probes containing the Remote_Branch tag
Get-Probe -Tags Remote_Branch

Get-Probe can be used as the input to Get-Sensor, Get-Device and Get-Group cmdlets, allowing you to easily filter based on a set of specified criteria

# Get all sensors under all probes containing "contoso"
Get-Probe *contoso* | Get-Sensor

To filter by custom fields the New-SearchFilter cmdlet must be used (alias: flt)

flt totalsensors greaterthan 10 | Get-Probe

For more information on New-SearchFilter see Filters

See Also

Clone this wiki locally