PRTG Custom Notifications: Outbound Calls on “Down” Alarm

The last blog I wrote about custom file sensor to track an abnormally large file and raise alarm based on that helped me gaining more confidence in PRTG. I am now of opinion that good folks at Paessler AG have tried their level best to make it as open as they could when it comes to customization and integration with other systems. It worked great with Powershell to figure out a problem that could collapse one of my applications, and also, it gave me another idea.

Problem Statement

We use SMS and Email as primary notification channels for any warning or down state alarm. I use Nova Launcher on Note 5 having bug of not showing Email Count on my Nine (for MS Exchange) email client. For SMS, we previously had a product that somehow didn’t turn out to be totally compatible as per our requirement, so we’re developing our own at the moment. Further to this, even if both of them work, they’re not ample enough to wake anyone of us in case something serious happens in night (P.S: We don’t entertain night duties). The best communication medium therefore in such duration of entire day is nothing but the GSM or PSTN calls and we decided to use Robot Calls for “Down” state cases.

Pre-Requisites

  • PRTG (Free or Commercial)
  • CTI Integration Knowledge with your Voice System
  • PRTG Admin Access

PRTG Custom Notification Settings

Login with PRTGAdmin Account or any other account with same permission level and go to Setup > Notifications.

2016-03-12 22_15_07-Windows 7 - Dev [Running] - Oracle VM VirtualBox
PRTG Setup Page
Now click on “Add New Notification” button at the bottom of this page.

2016-03-12 22_23_06-Program Manager
Click on “Add New Notification”

Give this Custom Notification a name and trigger action as per your accord. I wanted to have only Down State therefore I selected as per screenshot:

2016-03-12 22_25_10-Windows 7 - Dev [Running] - Oracle VM VirtualBox
Name & Summarization
Set Access Rights as per your environment:

2016-03-12 22_36_50-Windows 7 - Dev [Running] - Oracle VM VirtualBox
Access Rights
Here starts the real part. In notification actions you have to check on Execute Program option. Provide the credential set which is capable of executing this program. In my case, I wrote a Powershell Script that required admin privileges. Notice the Program File name “Notify.ps1” which is our script – the medium of communication between PRTG and External Application. As per Paessler, here you can Select the program that PRTG executes. You can choose from *.exe, *.bat, *.cmd, *.com or *.ps1 files located in the Notifications/exe subfolder of your PRTG installation. If this list is empty, please copy all files you want to appear to the executables directory.

2016-03-12 22_38_44-Windows 7 - Dev [Running] - Oracle VM VirtualBox
Execute Program Setup

PRTG Host Machine Settings

 

Go to C:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE OR C:\Program Files\PRTG Network Monitor\Notifications\EXE depending upon your 32 or 64 bit machine. This is the folder where you have to save your script. Just an idea about how I am doing it, we have a dialer with an option to keep on looking for a new number in DB table and dial it out the moment it finds one. So what I’m doing with this script is to execute a stored procedure in my MS SQL Server to update the records and once dialer finds it updated, there’s an outbound calls on all numbers inserted via stored procedure. The dialer with robot call option uses particular wav file (I generated one from here). You can use any other as per your requirement.

So here’s the Notify.ps1 making the execution of stored procedure possible:

===========================START===========================
$con = new-object "System.data.sqlclient.SQLconnection"
#Set Connection String
$con.ConnectionString =(“Data Source=mssqlserver.mydomain.local;Initial Catalog=HN_MSSQLDB;Integrated Security=SSPI;User ID=username;Password=mypassword”)
$con.open()
$sqlcmd = new-object "System.data.sqlclient.sqlcommand"
$sqlcmd.connection = $con
$sqlcmd.CommandTimeout = 600000
#Let's Call Remote Procedure
$sqlcmd.CommandText = “EXEC [HN_MSSQLDB].[dbo].[UpdatePRTG]”
$rowsAffected = $sqlcmd.ExecuteNonQuery()

#This section you can use for time stamping with little improvement.
$text = "Alarm Raised Again"
$text | Out-File "C:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE\test.txt"
#Exit 0 is important or the custom notification won't work.
exit 0;
============================END============================

To be honest, the script isn’t doing any extraordinarily intelligent stuff. It’s just communicating with SQL Server which further interacts with dialer. But the good thing is that we can do it pretty easily using PRTG.

Bringing it to Action

For some reason, I couldn’t get this part directly from Paessler’s stock documentation, so I have to use their forum from where I got a response pretty quickly within a day. It was simple enough. Simply navigate to the group/device/sensor for which you want to configure this notification, go to Notification Setting and create new notification as per your requirement. In my case, I wanted to do it for all of my machines and all sensors, so I went to the Root level and did my things as under which were then inherited across all the sensors:

2016-03-12 23_46_43-Windows 7 - Dev [Running] - Oracle VM VirtualBox
Select Root Level
And then create Alarm as under:

2016-03-12 23_52_47-Windows 7 - Dev [Running] - Oracle VM VirtualBox
Add Alarm with Custom Notification Created Earlier

Further Ideas

 

PROVIDED that I find some time, I will try to formulate more general standard setting to use minimal Asterisk based VM with SIP Trunk Setup to open the dialer part for organizations that may require it. Luckily, I didn’t have to work hard at this part in my scenario since we’re having Call Center as our core services.

Another idea is to let this setting be part of default PRTG Notification type, i.e. Email, SMS and SIP Calling (where user can provide SIP Details for calling).

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.