![]() |
You'll practically never ever see this. |
First, I hope it's clear that landlines are not immune from outages, either. And unlike an answering machine hooked up to your landline, your VoIP voicemail is handled at the server level, so callers can still leave messages even if your local Internet is down. Which, again, rarely happens around here...
But there's comfort in knowing the status of your complete VoIP system. Fortunately, my provider, voip.ms, provides an applications programming interface (API) that makes it simple (but geeky!) to have your Mac continuously monitor your VoIP-line status and alert you if there's an outage or even if your equipment is having problems. (My example code below is platform-independent, too, and can be adapted to whatever live-desktop and alert mechanism works for your computer.)
The trick is to leverage a wonderful utility called GeekTool to periodically check your account registration status on voip.ms' servers. GeekTool can run scripts, and it's pretty easy to make a script which will use voip.ms' API, display the status and even trigger an alert via another popular utility called Growl.
Here's how
First, download and install GeekTool. (
- Log on to your voip.ms account. In the tab marked "Main Menu", select the "SOAP and JSON/REST API".
- Scroll down to the bottom. Enable the API, assign a password (which can be different from your login password), and enter your IP address. Click the update buttons after each entry.
- Scroll up a bit, and look for the link that says "Click here to download Example Codes and API Documentation" Download this, unzip, and look for the folder entitled "Examples SOAP for PHP5." In this folder, look for the document "class.voipms.php".
- Open class.voipms.php using TextEdit. Put your account number and API password in it up top, then save it somewhere handy-- for example, I have a folder called "geekvoip" in my Documents folder.
Your account is now set up for automated access and monitoring. Here's a simple script which we'll call from GeekTool:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once("class.voipms.php"); | |
$voipms = new VoIPms(); | |
/* Account #1 */ | |
$account = "account_subaccount goes here"; | |
/* Get Registration Status */ | |
$response = $voipms->getRegistrationStatus($account); | |
/* Get Errors - Invalid_Account */ | |
if($response[status]!='success') | |
{ | |
echo $response[status]; | |
exit; | |
} | |
/* Is Registered */ | |
echo "{$account} Registered : {$response[registered]} | |
"; | |
if($response[registered]!='yes') | |
{ | |
exec ('/usr/local/bin/growlnotify -m "VoIP Down"'); | |
} | |
/* Account #2 */ | |
$account = "account_subaccount #2 goes here"; | |
/* Get Registration Status */ | |
$response = $voipms->getRegistrationStatus($account); | |
/* Get Errors - Invalid_Account */ | |
if($response[status]!='success') | |
{ | |
echo $response[status]; | |
exit; | |
} | |
/* Is Registered */ | |
echo "{$account} Registered : {$response[registered]} | |
"; | |
if($response[registered]!='yes') | |
{ | |
exec ('/usr/local/bin/growlnotify -m "VoIP Down"'); | |
} | |
date_default_timezone_set ("America/Los_Angeles"); | |
echo date("d M y H:i:s",time()) | |
?> |
![]() |
GeekTool. |
Copy that and paste into TextEdit. (Note my example is made to check two subaccounts-- the code is easily modified to handle any number.) Put your subaccount number(s) in it, and save it with a .php extension in the same folder you just saved class.voipms.php in. In my case, the file is named voip.php.
Now, open GeekTool. Drag a Shell object onto your desktop. In the Command field of the object, type a php command to execute the file you just saved. In my case, the command looks like:
php ~/Documents/geekvoip/voip.php
Good settings for the GeekTool object are a Refresh of perhaps 600 seconds and a timeout of maybe 20 seconds.
![]() | |
|