Hi,
is it possible to active and deactive single notification objects? We are three technicians who do emergency service seperately each week. Only the technician on duty should recieve alarm notifications. At the moment I active and deactive the notifications manually.
Article Comments
Hi lordmilko,
Exactly. Sorry I forgot to say that. We've got three types of Notification Objects. The first one sends an email to our ticket system. This notification should stay activated all the time. Then we have an objects for our support technicians and one for a third technician which have to be activated one week a month. At the moment we activate / deactivate this object manually once a month, but we would like to automate this step by script or another workaround.
May, 2018 - Permalink
Hi JSwitlinski,
You can programmatically toggle the Status of a notification trigger using PowerShell by combining the C# and PowerShell interfaces of PrtgAPI
The following demonstrates the principles you can employ to achieve this functionality
function ToggleNotificationActions($name) { # Connect to your PRTG Server. As a scheduled task, you should create a dedicated API user Connect-PrtgServer https://prtg.example.com (New-Credential prtgadmin prtgadmin) -Force # Construct a list each engineer's notification actions $actions = Get-NotificationAction "Ticket Notification","Email and push notification to admin" # Loop over each engineer and decide whether their action should be enabled or disabled foreach($action in $actions) { if($action.Name -like $name) { # Engineer is on call. Enable Write-Host "Enabling notification action $($action.Name)" (Get-PrtgClient).SetObjectProperty($action.Id, [PrtgAPI.ObjectProperty]::Active, $true) } else { # Engineer is off call. Disable Write-Host "Disabling notification action $($action.Name)" (Get-PrtgClient).SetObjectProperty($action.Id, [PrtgAPI.ObjectProperty]::Active, $false) } } } ToggleNotificationActions "*ticket*"
We can check whether the command worked - only disabling the "Email and push notification to admin" notification by executing Get-NotificationAction
C:\> Get-NotificationAction Name Id Active Email ---- -- ------ ----- Email and push notification to admin 300 False PRTG System Administrator Email to all members of group PRTG Users G... 301 True PRTG Users Group Ticket Notification 302 True None (Disabled) Email to all members of group PRTG Domain ... 7597 True PRTG Domain Administrators
Of course, in your script you will likely want to toggle the active engineer based on some kind of specified date range. A good solution would be to define a PSCustomObject that maps each engineer to the days they are on call; if the script detects the current day of the week is part of their roster, their notification action is enabled. Otherwise, it is disabled
Regards,
lordmilko
May, 2018 - Permalink
As an alternative, have a look at the PRObject tool. With this command line tool you can pause and resume any object, including notifications.
Using the tool in combination with the Windows Task Schedular you can create your own schedule for pausing and resuming.
May, 2018 - Permalink
Hi JSwitlinski,
When you say "deactivate" notification objects, are you referring to navigating to Setup -> Account Settings -> Notifications, selecting the desired notification and changing its status from Started/Paused?
May, 2018 - Permalink