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

How can I script SMS text message notifications for PRTG with Windows PowerShell?

Votes:

0

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?

bulksms custom-notification howto notifications powershell prtg script sms text-message

Created on Feb 3, 2010 9:56:19 AM by  Jörn Paessler [Paessler Support]

Last change on Dec 28, 2021 8:47:49 AM by  Frank Hadasch [Paessler Support] (0) 1



2 Replies

Accepted Answer

Votes:

0

This article applies to PRTG Network Monitor 7 or later

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:

Created on Feb 3, 2010 9:56:55 AM by  Jörn Paessler [Paessler Support]

Last change on Dec 28, 2021 8:49:06 AM by  Frank Hadasch [Paessler Support] (0) 1



Votes:

0

I would use biterscripting. I use it with http://websms.starhub.com/websmsn/usr/createMsgSessionPageShow.do?method=initCreateSession as follows.

# Script SendSMS.txt
var str mobile, msg
isstart sms
iscon sms "http://websms.starhub.com"
script ss_iscookies.txt from("sms") to("sms")
isret sms "http://search.starhub.com/query.html"("recipients="+mobile)  "senderName=me" "new=1" "numleft=1" ("message="+$msg)
isdiscon sms
isend sms

To test the script, copy and paste the script in file C:/Scripts/SendSMS.txt, then enter this command in biterscripting.

script "C:/Scripts/SendSMS.txt" mobile("1234567890") msg("Hello")

Of course, use the correct mobile number istead of 123456789. Also, make sure you can use your SMS website in this way based on user agreement.

You can find the documentation for the automated web commands at http://www.biterscripting.com/helppages_automatedinternet.html in case you need to customize this script for your SMS website.

Created on Apr 4, 2010 8:13:26 PM




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.