• Main
  • >
  • Blog
  • >
  • Tutorial
  • >
  • Sending Random SMS Notifications from PRTG network monitor Using NetPing
Tutorial
6/29/2015

Sending Random SMS Notifications from PRTG network monitor Using NetPing

Sending Random SMS Notifications from PRTG network monitor Using NetPing

Devices with enhanced features and a built-in modem, such as a gateway for sending and receiving SMS commands NetPing SMS, a device for remote monitoring of sensors via a network UniPing server solution v3/SMS and a device for remote controlling power supply sockets NetPing 8/PWR-220 v3/SMS have got a feature of sending random SMS notifications using HTTP API. This innovation can be used in the monitoring system PRTG Network Monitor to send SMS notifications about certain events in monitoring objects. As a result of organizing such system of SMS notifications PRTG Network Monitor, it is possible to save some funds using alternate services for sending SMS notifications, available on the Internet.

Requirements

To implement a functionality described above, there is a need to have:

  • a gateway for sending and receiving SMS commands NetPing SMS with an installed SIM card, a device for remote sensors monitoring UniPing server solution v3/SMS or a device for remote controlling power suppy sockets NetPing 8/PWR-220 v3/SMS  with an installed SIM card;
  • a prepared script on PowerShell for sending random SMS notifications about events in the monitoring system PRTG Network Monitor;
  • a configured monitoring system PRTG Network Monitor

PRTG Network Monitor Configuration

To configure SMS notifications in the monitoring system PRTG using HTTP API, there is a need to go to the tab «Setup» to adjust basic configuration of the system:

Основные настройки системы PRTG Network Monitor

Go to «Notifications» in the area «ACCOUNT SETTINGS» at the page of system settings of the system PRTG. All notifications are configured in «Notifications»:

Настройка уведомлений в разделе Notifications системы PRTG Network Monitor

The system will prompt to enter a system administrator's username and a password to get an access to the web page «Notifications»:

Авторизация в системе PRTG Network monitor

After a successful authorization, the table «NOTIFICATIONS» will appear, where a new notification should be added by clicking the button «Add new notification»:

Настройка нового уведомления на страницы NOTIFICATIONS в системе PRTG Network Monitor

At the page for configuring new notification «Add notification» indicate a notification name in the field «Notification Name», for example, «SMS Notification» and check the checkbox «EXECUTE PROGRAM». There is a need to fill in parameters in the configuration area «EXECUTE PROGRAM».

Настройка уведомлений методом Execute Program в PRTG Network monitor

where:
Program File – choose a file to run from a drop-down list (particularly the script PowerShell for sending random SMS notifications in this case). PRTG will run this file each time when conditions for this notification to trigger will be fulfilled. To choose a previously prepared script, it needs to be located via the next path: "C:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE". If the monitoring system PRTG consists of a cluster of servers, then executed file is necessary to be copied by represented path for each server in a cluster. This will prevent an issue of sending SMS notifications when one or several servers in a cluster are out of action.
Parameter – specify parameters that will be transmitted to the executed file when starting. For NetPing devices, there is a need to indicate a phone number in square brackets and an SMS text separated by a space to send SMS notification. In an SMS text, it is acceptable to use system variables of the PRTG Network Monitor. Kindly see a list of variables here.
Timeout – is time within which an operation of executed file will be interrupted if a process of executing a script has stuck.

After specifying all parameters of a new notification, there is a need to save settings by clicking the button «Save».

As a result, a new notification will appear in the table «Notification»:

Список уведомлений на странице Notifications системы PRTG

For a created SMS notification to work properly, it must be applied to necessary sensors or devices in the system PRTG.

Let us consider the example of using SMS notification, which will be triggered when a device disappears or appears in a local network. To do this, there is a need to choose a necessary device in the PRTG, which is checked for accessibility by the command «Ping». The choice is made at the page «Devices»:

Основное меню системы мониторинга PRTG

Just for an example, let us pick the device «Mail Server» out of the list of devices configured for monitoring at the page «Devices». A choice is made by clicking a mouse pointer on the name of a device:

Cписок устройств системы мониторинга PRTG

The page «Device Mail Server» will be opened, where all sensors of the device are represented. As it is obvious from a screenshot below, the device «Mail Server» is configured to check the availability only using the command «Ping»:

Список настроенных сенсоров в устройстве системы PRTG

To use a created notification «SMS Notification», there is a need to click the sensor «Ping» and go to the tab «Notifications»:

Применение уведомлений при срабатывании сенсора в PRTG

At the tab «Notifications» a response to the change in the status of sensors of a selected device is adjusted. To receive an SMS notification when a status of the sensor «Ping» is changed, there is a need to add a trigger by clicking the button «Add State Trigger» and fill in corresponding fields:

Настройка триггеров для срабатывания SMS уведомлений в PRTG

where:
1 – is a condition, within which a notification will be triggered. In this example, a trigger will be activated when a sensor is in the status «Down»;
2 – is a period of time, within which a trigger will work. This period of time allows to avoid false triggering;
3 – is a method for sending notifications when a trigger will work;
4 – is a method for sending notifications, when a condition is not fulfilled anymore;
5 – saving parameters of a trigger

Configuring Devices NetPing SMS, UniPing server solution v3/SMS and NetPing 8/PWR-220 v3/SMS

To send SMS notifications as in the example (i.e. using the devices NetPing SMSUniPing server solution v3/SMSNetPing 8/PWR-220 v3/SMS  as an SMS gateway) there is a need to perform only a part of a basic configuration (configure network parameters to access the network) of the devices NetPing SMS, UniPing server solution v3/SMS and NetPing 8/PWR-220 v3/SMS and insert a working SIM card with a positive balance into the slot of a built-in modem. You are welcome to read more about basic and additional configuration of devices in the documentation represented below:

Example of the PowerShell Script for Sending Random SMS Notifications about Events in the Monitoring System PRTG Network Monitor

Below you can see a code of a script on PowerShell. It needs to be copied into a text file and saved with the extension «.ps1» via the next path: "C:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE".

$url = "http://192.168.0.100/sendsms.cgi"
$username = "visor"
$password = "ping"

foreach ($arg in $args)
{
Write-Host "Arg: $arg";
}

$req = [System.Net.WebRequest]::Create($url)
$req.Method = "POST";

$req.Credentials = new-object System.Net.NetworkCredential($username, $password)

$Body = [System.Text.Encoding]::UTF8.GetBytes($arg);

$stream = $req.GetRequestStream();
$stream.Write($Body, 0, $Body.Length);

$stream.Flush();
$stream.Close();

$resp = $req.GetResponse().GetResponseStream()
$resp.Close() 

where:

$url – is a variable, which sets an IP address of a NetPing device and a script to send random SMS messages.
$username – is a variable, which sets a username to get authorized for the device NetPing.
$password – is a variable which sets a password to get authorized for the device NetPing.

On default, performing PowerShell scenarios in the system is prohibited because scripts may contain a malicious code, which is able to damage a system. It is possible to disable verification of compliance scripts. To do this, there is a need to run a PowerShell console from a name of a system administrator and enter a command:

Set-ExecutionPolicy Unrestricted

Kindly read more detailed information about a script execution policy in a PowerShell environment in the article «Using the Set-ExecutionPolicy Cmdlet».

Result

As a result of configuring sending SMS notifications about events in the monitoring system PRTG Network Monitor while using SMS gateway on the basis of the devices NetPing SMS, UniPing server solution v3/SMS or  NetPing 8/PWR-220 v3/SMS described above, a staff will receive SMS notifications similar to the one below:

NetPing device - SMS notifications


  • UniPing server solution v3
  • NetPing SMS

Main tags


All devices
All NetPing power
NetPing SMS
NetPing mini-UPS
NetPing 2/PWR-220 v1/SMS
UniPing server solution v3/SMS
UniPing server solution v3
NetPing /PWR-220 v3/ETH
NetPing IO v2
NetPing 4/PWR-220 v3/SMS
UniPing v3
Uniping server solution
NetPing 8/PWR-220 v3/SMS
NetPing 2/PWR-220 v2/SMS
NetPing 2/PWR-220 v3/ETH
NP-SM4
Temperature sensor T811, 2m
Temperature 1-wire, (THS), 2m
▼ All tags
New devices
Temperature sensor T811, 2m
Temperature sensor for measuring an ambient air temperature indoors from -40°C to +125°C. Avoid water details...

Price: 19 usd

UniPing server solution v3
A device for a remote monitoring of sensors via the Ethernet/Internet network. It allows to receive details...

Price: 180 usd

Humidity sensor WS-2
A relative humidity sensor for measuring relative humidity in % and a built-in temperature sensor.Plastic details...

Price: 42 usd

-+ usd usd
Subtotal usd

Your Order