Sending Out PRTG SMS Notifications Using a GSM Modem and the MWconn Freeware Tool
8 Easy Steps to Go
In some monitoring scenarios users want a notifications system that can alert independently from an existing IP (and internet) connection. We have already introduced several means to do so, but with MWconn it gets really simple.
PRTG already comes with IP-based SMS functionality which enables you to trigger and send out text messages to your mobile whenever there are alarms in your monitoring. IP-independent SMS dispatch can be achieved, for example, with a GSM modem connected to the machine running the PRTG core server in combination with some third party command line client which can send out SMS text messages via the connected modem.
There are several suitable tools available. Our partner ProComp gave us a valuable hint to a solution that even works with free software only.
In this article we will describe a sample setup using the well known Freeware tool MWconn. We have set up a test scenario using an Option iCON 225 GSM USB modem (also known as "T-Mobile Web'n Walk Stick") in combination with a prepaid card operating in the Vodafone network. Our test scenario runs well under Windows 7 x64 and can send SMS text messages with up to 160 characters (longer messages will be cut off in the current MWconn version). This setup is inexpensive, too: Searching the "bay", compatible USB GSM modems start from 20 EUR (new).
Please note: This article is intended for your information to demonstrate how you can add independent SMS functionality to PRTG easily. Very likely, the steps to go will vary for your individual setup, depending on Windows version, hardware, and network provider used. Please understand that we cannot provide any support regarding the functionality of third party software, nor answer specific questions regarding hardware configurations.
Step 1: Check for Compatible Hardware
There is only a selection of GSM modems which work well with MWconn. In order to find a compatible device, please have a look at the "Data Cards" list in the MWconn wiki.
Step 2: Install Your Hardware
On the computer running your PRTG core server, install the modem using the correct drivers (we found drivers on the manufacturer's website). Make sure that the hardware is installed correctly and that no modem management software (running in the system tray) is blocking access to the modem.
Step 3: Download and Install MWconn
Download the Freeware tool and install it.
In our test, we downloaded version 5.7 and installed it directly on the computer running our PRTG core server, into the folder
C:\mwconn
We assume you use the same folder.
Step 4: Configure MWconn
In the installation directory, start the "CONFIG.exe" file with Administrator rights. MWconn is mainly intended to provide internet access via GPRS/UMTS. As we only want to use SMS functionality, there are just a few specific settings we want to change here. Our SIM card does not require any PIN code.
Global Tab
In the "Global" tab, in the section "Standard settings", select the network provider from the list (you will find several for almost every country). Apply your selection by clicking on the "Confirm" button.
This will set the short message service center (SMSC) to the correct number. This setting is needed to successfully send out SMS messages. If you do not find your network provider in the list, go to the next step.
Network Tab
In the "Network" tab, in the "SMSC" section, make sure the correct short message service center number for your network provider is shown. It should be right if you successfully could apply settings in the previous step. Change the number if needed.
We do not pay attention to the other settings in this tab.
Connection Tab
In the "Connection" tab, disable automatic start and set the "Connection mode" option to "dial-up". This is because we do not want MWconn to establish any data connections.
Start/End Tab
In the "Start/End" tab, we will tell MWconn to set up itself as a Windows service on the computer running the PRTG core server. This way, it will start-up automatically after a server reboot and will be available even if no user is currently logged in to the server (just as the PRTG services themselves).
Make sure you started "CONFIG.exe" with Administrator privileges. From the "Rules for program start" section, choose "GPRS.exe" from the drop-down menu. For best network coverage, do notchoose one of the EXE files containing "UMTS". This way you make sure your modem connects to the nearest available cell on the mobile network, no matter if this cell supports UMTS or not.
Click the "Confirm" button and confirm the following messages. MWconn will tell you that you will need a "CONTROL.exe" file if you want to see GUI output for the program running as service. Confirm with "Yes" to create it.
MWconn is now set up as a Windows service. Open "services.msc" to check if creation was successful. There should be an entry called "MWconn_Internet" with start type "Automatic", running under the "Local System" user account.
Leave the "CONFIG.exe" program by clicking on the "OK" button.
Step 5: Start MWconn
From the installation directory, start "MWconn.exe". Make sure your GSM modem is recognized successfully. It might take a few seconds until the modem is initialized and connects to the mobile network. Eventually you should see your network provider's name and the signal strength.
"up" and "down" will both be shown as "offline", as we previously disabled automatic network connections. This is okay. MWconn is now ready to send out SMS text messages.
Step 6: Understand How Sending SMS with MWconn Works
Check the MWconn user manual in your installation directory to understand how sending SMS works.
From the MWconn Manual
«MWconn provides other programs with the option of sending short messages. To make this process uncomplicated and also facilitate the usage of batch files, data exchange per files is used in this case. For this purpose, MWconnchecks on a regular basis, whether a file whose name meets the formatsms_ExampleApplication__155500123.txtexists in the folder sms_send in MWconn working directory. If yes then the text that is contained therein is sent and subsequently the file is moved to the folder sms_out. The destination address must be provided in international format, the plus sign is omitted in the file name. The maximum text length is 160 characters, i.e. no 'long SMS' can be sent in this case.
Example of application: In case you want to send an SMS from a new batch file (e.g. senden.bat), then generate this file with the name "send.bat" and the following content:
echo Hello, this is an automatically sent SMS. >sms_send\sms_test__155500123
Double-clicking on the icon of "send.bat" will send an SMS with the above-mentioned content and to the number +155500123.
[...] In order to prevent duplication of SMS that is sent or that it is continuously sent across in the case of a program error, MWconn sends the consecutive SMS with the same destination and same content only post lapse of a time lag of ca. 3 minutes since the time of the last send action.»
In a Nutshell
Basically, PRTG just needs to create a text file in a specific format and save it to an "sms_send" folder in the MWconn directory, in our case:
C:\mwconn\send_sms
MWconn will check this folder and send out SMS messages automatically. Processed files will be moved to the "sms_out" folder. Only the first 160 characters of each message will be sent; all other content will be cut off.
Optional: Test It
You can test SMS sending if you run "MWconn.exe", create a text file in the according format and move it to the "sms_send" folder.
After a few seconds, the program will show a "Sending SMS" message and again after a few seconds you should receive the message on the target device.
Step 7: Prepare PRTG Notification
If not done yet, reboot your server to start MWconn as a Windows service, or start the "MWconn_Internet" service manually.
In the "Notifications\EXE" sub folder of your PRTG installation directory, create a new batch file
mwconn.bat
In the file, save the following content:
echo "%~2" >"c:\mwconn\sms_send\sms_PRTG-%date:/=%-%time::=%__%1.txt"
This batch file will expect two inputs as parameters, a phone number and a message, and create a new text file using MWconn compatible naming and content. File names will also contain an ID based on the current time in order to make them unique (the ID is parsed for incompatible characters typical for date/time values).
Step 8: Add PRTG Notification
In the PRTG web interface, create a new notification using the "Execute Program" method. In the "Program file" drop down, select the "Mwconn.bat" entry.
In the "Parameter" field, enter
- the recipient phone number in international format, with leading country code but without plus (+) sign
- the message that will be sent, in double quotes.
Put a space between the these two parameters.
For example, enter
1555123456 "[%sitename] %device %name %status %down (%message)"
This will create an SMS message to the US number +1-555-123-456 containing some default information about the sensor which triggered the notification.
Please note that the message must be written in double quotes (") to make sure it is regarded one parameter. Only the first 160 characters of the message will be sent.
Save the notification and test it by clicking the "Test" button in the notifications list. You should receive a test SMS shortly.
Now set up notification triggers in PRTG just as usual to trigger your new SMS notification.
Debugging
If you have problems sending SMS messages with such a setup, please make sure your MWconn Windows service is up and running. From the MWconn installation directory, start "CONTROL.exe" to see the output of the MWconn instance running as Windows service. This window should show your mobile network name and coverage. It will as well show a message while an SMS is sent.
Create a new text file with the name
sms_test__1555123456.txt
In the filename, replace 1555123456 by your own mobile number in international format, omitting the leading plus (+) sign. Open the text file and write the word "test" in it. Save it.
In the MWconn installation directory, create a "sms_send" sub folder (if it does not yet exist) and copy the newly created text file to this folder. The SMS containing the word "test" should be sent to your mobile number after a few moments.
If the SMS is not sent, please check the SIM card and make sure you are allowed to send SMS with it.
If you like MWconn, please consider donating to the author to support this project