Monitoring Your Network with PRTG - Custom Notifications

Articles in this series:

In past articles, I discussed and overview of the PRTG Network Monitor along with some info on creating your own sensors to customize your monitoring experience.  In this article, I’m going to dig into alerting and notifications.

PRTG’s Flexible Alerting

No monitoring system would be useful without a system to alert the users when something goes wrong.  Like it’s sensor subsystem, PRTG is very flexible in the configuration of alert notifications and even goes so far as to allow you to create your own alert notification scripts if you want to do something beyond their built-in support for Email, SMS/Pager, syslog, SNMP Traps, HTTP requests, Event log entries, alarm sound files and Amazon SNS.

State Triggers

The way alerts work is that you can create custom “State Triggers” on the objects you create.  The triggers can be inherited in your object hierarchy to make it easier to share configuration across all of your objects.  State triggers can be configured based on:

  • Status - an objects status is up, down, or warning
  • Limit - an object’s value goes above or below a specified value.
  • Threshold  - an object’s value goes above or below a specified value for a set number of minutes
  • Multiple Condition - objects x and y having certain state conditions
  • Escalations - Extra notifications every “x” minutes during downtime
  • Dependencies - This will help avoid false alarms.
  • Alert Scheduling - set a time window when certain priority events will not be sent.


Above is a setting we have for one of our external VIPs for DevCentral.  We have it setup so that if any of the child sensors are marked “down” for 60 seconds, the “DCOps Notification (Email + SMS)” notification event is performed.

The notifications are configured by clicking on the “Setup” menu and then picking the “Notifications” menu under the “Account Settings”.

At that point you can configure the default monitors.  Email has it’s own section and all you have to do is specify an email address, subject, and the message body.  We just relied on the default templates provided by PRTG which worked great.

Email is great, but things get lost in there and we wanted a way to send a second type of notification to our Operations team to make sure they got it and no better way than sending a text directly to their phones.

Configuring SMS wasn’t quite as easy as email.  The built-in SMS options rely on 3rd party services that charge a fee for their services.  I’ve been writing scripts for a long time that have sent texts to my phone so I thought there had to be a way to adapt that into this system - and of course there was!

Custom Alerting

PRTG allows for you to write your own custom programs that the notifications will run when a notification needs to occur.  This is configured in the “Execute Program” section of the Notification configuration as shown below.

Custom Notification - Notify-SMS.ps1

Since I’ve already written the SMS code in PowerShell, it was a no brainer to whip up a script

In the configuration I’ve included the PRTG parameters for the Device, Name, Status, Down state, Date and Time, and the Status message in the parameters to the script.

The big question you are probably asking is how it’s sending an SMS message.  Well, Verizon and AT&T, which our team has our cell phones on, have a SMS gateway through email.  By sending an email to your cellphone number to the providers gateway, it will get sent to their phones as a text message!  Verizon uses “” and AT&T uses “”;

In the script I define the dev-ops team that will receive the notifications and it then calls the PowerShell Send-MailMessage Cmdlet to send it off to our phones.  This was a lot easier that using a costly SMS gateway.

   1: param (
   2:   $To = "dcops",
   3:   $Device = "device_unknown",
   4:   $Name = "sensor_unknown",
   5:   $Status = "",
   6:   $Down = "down_unknown",
   7:   $DateTime = "datetime_unknown",
   8:   $Message = "message_unknown"
   9: );
  11: $JOE = "";
  12: $FRED = "";
  13: $BIFF = "";
  14: $SKIP = "";
  16: $DCOPS_SMS = @(
  17:   $JOE,
  18:   $FRED,
  19:   $BIFF,
  20:   $SKIP
  21: );
  23: $DCOPS_TEST = @(
  24:   $JOE
  25: );
  27: function Send-SMSMessage()
  28: {
  29:   param(
  30:     $To = $(Throw "Must supply To"),
  31:     $Subject = $(Throw "Must supply Subject"),
  32:     $Body = $(Throw "Must supply Body"),
  33:     $From = "",
  34:     $SmtpServer = "localhost"
  35:   );
  37:   $enc = [System.Text.Encoding]::UTF8;
  38:   Send-MailMessage -To $To -Subject $Subject -From $From -Body $Body -SmtpServer $SmtpServer -Encoding $enc;
  39: }
  41: if ( ("" -ne $Device) -and ("" -ne $Name) -and ("" -ne $Down) -and ("" -ne $DateTime) -and ("" -ne $Message) )
  42: {
  43:   $Subject = "PRTG!";
  44:   $Body = "$Device $Name $Status $DateTime $Message";
  46:   if ( $To.ToLower() -eq "dcops" )
  47:   {
  48:     $To = $DCOPS_SMS;
  49:   }
  51:   Send-SMSMessage -To $To -Subject $Subject -Body $Body;
  52: }
  53: else
  54: {
  55:   Send-SMSMessage `
  56:     -To "" `
  57:     -Subject "Notfiy-SMS Error" `
  58:     -body "Device($Device),Name($Name),Down($Down),DateTime($DateTime),Message($Message)";
  59: }


As I’ve mentioned before, PRTG is very flexible, but it’s ability to let you customize each of the components by external scripts is what really makes it shine in my book.

Happy Scripting!

Published Oct 09, 2012
Version 1.0

Was this article helpful?

1 Comment

  • Joe, thanks for this. I know this is three years old at this point, but I implemented this and it works almost perfectly. Obviously I swapped all of your info out with mine and my environment, and the UP messages work fine, delivered flawlessly. But all of the DOWN messages generate the error e-mail. But they contain all of the relevant information! Any thoughts?