Hi guys, i was wondering if you had any pointers on how to collect the alerting/notification settings for every sensor on our prtg server so we can audit them and make sure they are standardised.

Im looking for

  • Limits Enabled - y/n
  • Thresholds for sensors Alarm and Warn
  • If possible what notification triggers exist for a device I.e just a ticket or email groups.

However i need this on a large scale for everything. Any API pointers greatly received, i also use LordMilkos API suite if he is about :)


Article Comments

Hi Samuel,

This can be achieved with the Get-Channel and Get-NotificationTrigger cmdlets of PrtgAPI. For more information, see Channels and Notification Triggers on the PrtgAPI wiki

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
C:\> Get-Probe | Get-NotificationTrigger

Type        ObjectId SubId Inherited ParentId Latency Condition Threshold Units      OnNotificationAction
----        -------- ----- --------- -------- ------- --------- --------- -----      --------------------
Change      1        8     False     1                Change                         Ticket Notification
State       1        1     True      0        600     Equals    Down                 Email Administrator
Threshold   1        7     False     1        60      NotEquals 5                    Email PRTG Alerts Mailbox
Speed       1        5     False     1        60      Above     3         TByte/Day  SMS Escalation Team 1
Volume      1        6     False     1                Equals    6         KByte/Hour SMS Escalation Team 1

Regards,

lordmilko


May, 2018 - Permalink

Hey there LordMilko! I actually figured this out from the docs of prtgapi about 15s after i posted it but then the edit feature wouldnt work. Do you by any chance know how to include device/sensor name in the get-notificationtrigger output? I'm happy working with objids but this spreadsheet is going to head honchos who need names, numbers and charts :)


May, 2018 - Permalink

Hi Sam,

The API calls made by Get-NotificationTrigger do not return that information, however this can be achieved very easily with a bit of PowerShell magic

C:\> $triggers = Get-Probe | foreach { $_ | Get-Trigger | Add-Member Name $_.Name -PassThru }
C:\> $triggers | fl

Name                         : Local Probe
ObjectId                     : 1
ParentId                     : 0
Inherited                    : True
Type                         : State
TypeName                     : State Trigger
SubId                        : 1
Latency                      : 600
Channel                      :
Unit                         :
OnNotificationAction         : Ticket Notification
OffNotificationAction        : None
Threshold                    : Down
Condition                    : Equals
EscalationLatency            : 900
EscalationNotificationAction : Ticket Notification
RepeatInterval               : 0

Instead of piping Get-Probe straight into Get-Trigger, we pipe it into a foreach cmdlet that performs three functions

1. Retrieves all triggers from the input Probe

2. Adds a new property "Name" to each trigger containing the name of the input Probe

3. Writes the updated input Probe to the pipeline

You will also find an example showing this exact technique on the Channels page of the wiki, showing how the name of each Sensor can be added to each channel

Regards,

lordmilko


May, 2018 - Permalink

holy frijoles... you're a savior ma dude :)


May, 2018 - Permalink

I am trying to run an audit like the others here with PRTG API and powershell, thank you for creating this. However, I need to get the device name that such sensor is associated with. that way I dont have to do look ups for each sensor ID

I hope there is a way to pipe that in?

Please advise. thank you again


Oct, 2019 - Permalink

You can use the Add-Member technique in this post

# List all sensors of all triggers, additionally including the sensor name and sensor device on each item
C:\> $triggers = Get-Sensor | foreach { $_ | Get-Trigger | Add-Member Name $_.Name -PassThru | Add-Member Device $_.Device -PassThru }

Oct, 2019 - Permalink