-
-
Notifications
You must be signed in to change notification settings - Fork 38
Channels
Channels can be retrieved for a specific sensor via the GetChannels
method.
//Retrieve channels for the sensor with ID 1234
var channels = client.GetChannels(1234);
//Retrieve the channel for the sensor with ID that matches the specified name
var channel = client.GetChannels(1234, "Total").First();
When retrieving a particular channel you insist should exist, it is possible to use the singular GetChannel
method, returning a single Channel
rather than a List<Channel>
as with GetChannels
.
GetChannel
supports filtering by either the channel name or channel ID
var channel = client.GetChannel(1001, 1);
var channel = client.GetChannel(1001, "Total");
If exactly one channel with the specified ID or name is not returned, GetChannel
will throw an InvalidOperationException
. If you are not sure whether exactly one channel with the specified ID or name exists, you should use GetChannels
instead and check for the presence of any results.
var channel = client.GetChannels(1001, 1).SingleOrDefault();
if (channel != null)
Console.WriteLine($"Found exactly one channel: '{channel}'!");
When interfacing with channels, it is important to note that the DisplayLastValue
property represents the display value of the channel e.g. 2000 kbit/s whereas the LastValue
property represents the value using the lowest possible unit (i.e. bits, bytes, seconds, etc). If want to be able to retrieve a numeric representation of the DisplayLastValue
in its display unit, you can optionally write an extension method to do this for you. In addition, if your PRTG user does not have write access to the target sensor, properties relating to channel settings will not be displayed.
For information on modifying the properties of a channel, please see Property Manipulation
Channels for one or more sensors can be retrieved via the Get-Channel
cmdlet.
C:\> Get-Sensor | Select -First 1 | Get-Channel
Name SensorId Id LastValue LimitsEnabled UpperErrorLimit LowerErrorLimit ErrorLimitMessage
---- -------- -- --------- ------------- --------------- --------------- -----------------
Total 3001 0 0.32 % True 95 PANIC!! PANIC!!!
Processor 1 3001 1 <1 % False
Channels can be filtered from output by specifying a name filter.
C:\> Get-Sensor | Get-Channel *total*
By default Get-Channel
displays a limited subset of properties. To view all properties returned from the respect, pipe the request to Select-Object
, Format-List
or Format-Table
(optionally specifying a search filter)
C:\> Get-Sensor -Count 1 | Get-Channel | fl *limit*
LimitsEnabled : True
UpperErrorLimit :
UpperWarningLimit :
LowerErrorLimit : 20
LowerWarningLimit : 30
ErrorLimitMessage : PANIC!!
WarningLimitMessage : PANIC!
When interfacing channels, it is important to note that the LastValue
property displayed in table view represents the DisplayLastValue
of of the Channel
. The true LastValue
property contains the raw last value of the channel using the lowest possible unit (i.e. bits, bytes, seconds, etc).
C:\> Get-Sensor *mem* | Get-Channel *mem* | fl Name,*Last*
Name : Percent Available Memory
DisplayLastValue : 27 %
LastValue : 27
Name : Available Memory
DisplayLastValue : 1,116 MByte
LastValue : 1169711104
In addition, if your PRTG user does not have write access to the target sensor, properties relating to channel settings will not be displayed.
Channel
objects returned by Get-Channel
only contain the ID of the sensor they belong to. If you wish to include the sensor name in your query, this can easily be achieved via the Add-Member
cmdlet
Get-Sensor | foreach { $_ | Get-Channel | Add-Member SensorName $_.Name -PassThru }
For information on modifying the properties of a channel, please see Property Manipulation