Using Selenium to monitor Phone Power international call usage

By | April 20, 2014

Back when I was using Vonage, I wrote and shared a Selenium script to alert me automatically if I was approaching my monthly usage limits.

Then I kicked Vonage to the curb and switched to using Google Voice plus an OBi202 box for my home phone service, lowering my monthly bill from around $14 for Vonage to $Free for Google Voice.

Alas, as of May 15, 2014, Google Voice is no longer going to work with my Obihai box, so I’m back to paying for VoIP. I decided on Phone Power‘s $5/month special offer (I have a sneaking suspicion it’s going to go up after the first year, but we’ll see) for former Obitalk Google Voice users. Alas, Phone Power has the same problem as Vonage — they let you view on your web site how many minutes you’ve used toward your quota of free monthly international minutes, but they don’t have any sort of automated alerts when you’re approaching your limit.

So I went ahead and tweaked my old Vonage Selenium script to work with Phone Power instead. For anyone who might find them useful, I’ve posted them in this public gist.

Here are the prerequisites you need to use these scripts:

  • Download the Selenium Server JAR file from http://docs.seleniumhq.org/download/ and save it somewhere.
  • Find the java command in the cron script and update the path name of the Selenium Server JAR file.
  • Make sure you have java, Xvfb, and nmap installed and in your search path.
  • Make sure you have the WWW::Selenium Perl module installed. On my Fedora system, I was able to do “sudo yum install 'perl(WWW::Selenium)'” to get it from the yum repository.

Here’s how to use the scripts:

  • Save the two scripts to disk as phonepower-usage-cron.sh and phonepower-usage.pl and make them executable.
  • Create the file ~/closed/pp-config.pl which sets the $pp_username and $pp_password Perl variables to your username and password for the Phone Power site. You can put the file somewhere else as long as you edit the line in phonepower-usage.pl that loads it.
  • If you saved phonepower-usage.pl somewhere other than ~/scripts, edit the invocation of it in phonepower-usage-cron.sh to point at the correct location.
  • Run phonepower-usage-cron.sh in an interactive shell and you should see one of three things:
    • an error if something went wrong;
    • a message telling you your current usage if it’s more than 75% of your monthly limit; or
    • no output at all if your current usage is less than 75% of your monthly limit (if you want to confirm that this is happening, add “--debug” to the phonepower-usage.pl invocation in phonepower-usage-cron.sh).
  • If you don’t see what you’re expecting, then you can look in /tmp/*.X.log and /tmp/*.selenium.log to see if there’s any information there about failures, or you can set XVFB to false at the top of phonepower-usage-cron.sh to watch Selenium working on your desktop rather than in a virtual X display.
  • Put an entry in your crontab to run the script daily, and it’ll generate output which cron will presumably mail to you when you’re close to exceeding your limit.

Note that Phone Power has a cheaper plan which limits domestic as well as international minutes. This script doesn’t check the domestic limit because I’m not using that cheaper plan, but it should be trivial to modify it to do so. If you can’t figure out how to do it and you need that functionality, email me and I’ll see what I can do (I’m not going to bother if no one actually needs it). Of course you can also tweak the script if you’d like it to use a different alert threshold than 75%.

Share and enjoy!

Print Friendly

One thought on “Using Selenium to monitor Phone Power international call usage

  1. Tom

    I was searching how the billing was done by phonepower after 60 minutes, it is bad that they do not have a feature to stop the calls after 60 minutes 🙁

    Thanks for the script, i will try this.

    Reply

Leave a Reply

Your email address will not be published.