Awareness is key to solving any problem — especially when it comes to the performance of your hosted servers. Personally, I go so far as to have my servers send me SMS (small message service) text messages to my mobile phone when something’s amiss. Based on scripts I set up, I get reports on events such as:
- When my hosted server has served more than 100 customers in the last hour.
- When a filesystem has run out of disk space.
- When I want an update on measurements or calculations I code such as the average load time of all pages delivered in the most recent ten minutes.
The best part: Setting up alerts is easy. Many gateways between SMS and email are already available under a variety of terms, and some are completely free for small volumes of transmitted SMS. How’s that for handy? Keep reading for more on how you can set up your hosted server to send you SMS text messages.
The good news: the server script is simple
I’ve illustrated the setup below with a fundamental example — a tiny script known as text_me.sh that consists of:
MY_NUMBER=XXXXXXXXXX MESSAGE="$1" echo "$MESSAGE" | mail $MY_NUMBER@txt.att.net
When the server executes the following:
text_me.sh "Server 15 disk space is getting full."
my mobile phone receives this:
FRM:Cameron Laird MSG:Server 15 disk space is getting full. 4:06 AM
Take a moment to consider several aspects of this example:
- It represents the potential to invert the server/admin relationship; instead of the admin checking on how it’s doing, the server can tell the admin when it has something to say. That’s a little more like the server serving you versus you serving the server.
- It’s painless. In fact, it only takes a few keystrokes to achieve this automation.
- It uses the ten-digit phone number format used in the United States, Canada, and a few other countries. If your mobile phone system uses a different format, you might need to experiment.
- It’s flexible. Other shell scripts can invoke text_me.sh, or you can tie in this same functionality to essentially any other programming or automation environment. Use text messages for alarms, reports, updates, and everything in between.
But with the good, also comes the aw-man aspects covered below.
The bad news: the script is carrier-specific
Unfortunately, text_me.sh only works with numbers serviced by AT&T Wireless. For the most part, this is a minor inconvenience. I regularly use several of the email-to-SMS gateways generously compiled by Martin Fitzpatrick to send SMS messages to other cellular networks’ users via email.
For example, if I want to include in my alarms a colleague whose phone is on T-Mobile, Fitzpatrick’s reference tells me (correctly!) that I direct my email to XXXXXXXXX.firstname.lastname@example.org.
Several service providers provide technical alternatives to text_me.sh. For a range of prices and complexities, they will tie your computer to larger or smaller portions of the world’s SMS-receiving population. In many cases, they can detect which carrier has provisioned a specific wireless phone number, and adapt the messaging accordingly. Those commercial offerings are better if you plan to reach a wider audience, such as customers, with SMS messages.
For a first step into this market, a carrier-specific limitation isn’t so bad when you consider the tradeoff: a short script you control. Honestly, it’s my preferred combination of simplicity, reliability, low cost, and ease of maintenance for sending alerts to administrators. I wouldn’t use it for everything, though, such as contacting customers.
Warning for the weary
Beware that the telcos aren’t consistent. For this reason, I suggest running periodic tests on your SMS channel and implementing failsafe or backup communication channels. If you run into issues or have questions or feedback on setting up your host server to send text message alerts, ping me in the comments section below.