SMS Notifications Through SMS Gateways

April 17, 2010

The use of SMS gateways has proliferated the uses for SMS notification and alerting. Ever more creative events may trigger an SMS alert.
The typical uses for SMS notifications sent through SMS gateways are those implemented for banking transactions, announcement of sales or special offers from a store that has your details, or even extreme weather warnings or breaking news alerts. An often overlooked use, arguably more relevant and useful to many, is the configuration of alerts for events or systems closer to the individual’s immediate interests.
Not only can many online SMS gateways allow the user to schedule SMS alerting at a preset future date – perhaps a reminder of a an important meeting or the need to buy a present a few days prior to a loved one’s birthday – but users can generate alerts from applications of their own for events that would otherwise not easily be used to trigger a message.

As an example, I recently had the need to generate an alert for myself shortly after a given webpage, on a server that I administer, had been viewed. Since this could happen at any time of the day or night, there was value in having an alert come to my cell phone through any of the available SMS gateways, wherever I may be.
A new page was added at a URL not unlike the following:

http://www.mycompanyname.com/campaigns/new-page-2010.php

It was critical to know when this page was hit the first time, not by interrogating logs the following day, but immediately after it occurred. Now it may seem that it would be an option to embed code within the page to trigger the SMS message alert transmitted through any one of the applicable gateways, however changes to the page were not possible after deploy and so only some auxiliary indicator (in this case http logs) would be usable.
A cronjob was setup to check the weblogs every 5 minutes. It is known that no more 1,000 hits are likely on this particular site in a 5 minute period and so only the last 1,000 log entries are checked. The server in question runs Linux, the cronjob in /etc/cron.d/alert_on_campaign looked like this:

*/5 * * * * root /usr/local/scripts/alert_on_campaign.sh

In turn, the script being called looked as follows:

#!/bin/bash
if [ `tail -10000 /var/log/httpd/default-access_log | grep new-page-2010.php | wc -l` -gt 0 ]; then
wget –delete-after “http://api.mysmsgateway.com/http/sendmsg.php?&api_id=12345&user=myusername&password=mypassword&to=12345678&text=New campaign page 2010 has just been hit”;
fi

The “if” line establishes whether 1 or more occurrences of the URL we’re looking for has appeared in the last 1,000 lines of the log in the past 5 minutes, the action then to call the URL at any one of the applicable online SMS gateways that will generate an SMS alert to the cell phone number 1234678.

A quick, but still effective, hack which simply looks for the occurrence of the new webpage in question and calling the convenient HTTP/S API for message sending at the chosen online SMS gateway(s). The alerts will repeat every 5 minutes after the initial alert if the entry remains in the last 1,000 lines of the web server log file, however for the current purpose action would be taken upon the initial hit and the cronjob disabled.)
The solution detailed above addressed the immediate need precisely. While there may be tools available on the internet, freely perhaps, to generate alerts via email or URL call (both supported as a means to generate an SMS by most online SMS gateways) for events appearing in a log file, the example detailed here illustrates what can be done in a matter of minutes. Similarly, what appears to be a quick and dirty solution, may suite many other requirements for quick, ad hoc alerting. Perhaps this trivial example reveals a means to add alerting some event you’ve been struggling to catch.

Need more information? Just click to read more about SMS Gateways…

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Tags: , , , , , ,

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

No Comments Yet

Join the Discussion