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

Activate/Deactivate Notification object via script

Votes:

0

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.

automatic notifications prtg

Created on May 11, 2018 2:52:45 PM



5 Replies

Votes:

1

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?

Created on May 17, 2018 5:23:39 AM



Votes:

0

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.

Created on May 22, 2018 6:38:41 AM



Votes:

1

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

Created on May 22, 2018 6:59:01 AM



Votes:

0

This might be a good solution to our problem.

Thank you very much!

Created on May 22, 2018 7:32:26 AM



Votes:

1

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.

Created on May 22, 2018 10:00:33 AM




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.