This article applies to PRTG Network Monitor 7 or later
I would like to receive an SMS text message notification to my mobile phone when a sensors goes down. My SMS provider is bulksms.co.uk. How can I do this?
Demo 'PowerShell' Notification for PRTG Network Monitor
PRTG Network Monitor is a network monitoring tool that offers multiple possibilities to send notifications on important events, for example when a device or individual sensors are down, thresholds are breached, devices fail to respond in a timely matter, etc.
To alert the user PRTG can use pre-defined or custom SMS delivery service providers (“SMS gateways”). If these do not meet your needs PRTG also allows you to create your own notification mechanisms using script files like batch files or PowerShell scripts.
The following PowerShell demo script shows a sample how to create a custom SMS notification using the service provider bulkssms.co.uk. It can easily be adapted for other services as well.
The script must be copied into the 'notifications\exe' folder of your PRTG core server installation.
# Demo 'PowerShell' Notification for Paessler Network Monitor 7.x # Sends a SMS by calling http://www.bulksms.co.uk. # To use it you need a valid account with 'BulkSMS' # # How to use it: # # Create an EXE notification within PRTG, select 'Demo Exe Notification - Sends SMS via BulkSMS.ps1' as program, # The parameter section consists of three parameters: # # - Username # - Password # - Message # # e.g. # # myusername mypassword '%device %message' # # Note that the third parameter needs to be within quotation marks, otherwise it is considered as multiple parameters. # Adapt error handling to your needs. if ($Args.Count -eq 0) { write-host 'No Arguments' exit 1; } elseif ($Args.Count -eq 3) { $str = [System.Uri]::EscapeDataString($Args[2]); $url = "http://www.bulksms.co.uk:5567/eapi/submission/send_sms/2/2.0?username=" + $Args[0] + "&password=" + $args[1] + "&msisdn=491743041972&message=" + $str $req=[System.Net.HttpWebRequest]::Create($url); $res = $req.GetResponse(); write-host $url; exit 0; } else { write-host 'Wrong number of arguments'; exit 2; }
Security Issues
It's a good practice to not enter passwords, parameters, etc. directly into your script. Instead, you can use the parameter field in PRTG to hand over these values to your script when calling it.
Information about signing PowerShell scripts and the Execution Policy for scripts can be found in the following external resources:
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.