Track your VPN Connection with VpnTint

If you’re like me, getting stuck with an unreliable network connection or finicky VPN can be a major source of frustration. Worse, it’s often unavoidable. When faced with a unique UI bug or validating that a new UI looks good with real data, I often need to use production data, which at New Relic means connecting to a special VPN.

Dropped connections can also be difficult to notice visually. On OS X, you don’t get much beyond the “connected timer” in the menu bar disappearing. On a large screen like our beautiful 27″ displays, this may be too subtle. Faced with this, I set out to find a way to make the VPN connection status more obvious. I’d gotten some inspiration from this Timebar, a creative timer using menu bar animations, I looked to tint the menu bar while the VPN is active.

As I looked into how to accomplish this, I found two areas that needed further research. First up: how to monitor the VPN’s connection status. After exploring the information available through utilities like defaults and route, I found OS X’s System Configuration Framework. I began by using scutil to explore what keys were available for network status, and what keys to watch to find out when something changed. I settled on State:/Network/Service/[^/]+/IPv4, which shows me anytime the IPv4 address(es) of the system change. The regular expression captures the network service’s UUID, which can then be used to find the user defined name of network at the key Setup:/Network/Service/.

Second item to investigate: how to tint the menubar. Though some open-source solutions existed, most resulted in the menu bar color flashing, which would be very distracting and unpleasant. I contacted the makers of Timebar and one of their developers, Mark, graciously provided tips on how to correctly style and place a window in order to tint the menu bar. With the final pieces of the puzzle in place, I got to work.

I dubbed my new Utility “VpnTint”, which runs in the menu bar. Based on feedback from my fellow Relics, a notification is displayed on VPN connect/disconnect when using Mountain Lion or newer, and the menu bar is tinted from a preselected palette of colors. For users who would like to define a color, the OS X user defaults system is used — check out the command defaults read org.ericbetts.VpnTint to get an idea.

Here’s how it looks!

Menu Bar Before VpnTint (while connected)

vpntint before

Menu Bar After VpnTint (while connected)

vpntint after

If you’d like to give it a try, releases (and full source code) are available on GitHub. Here at New Relic, it’s been a particular success with the site engineering team. Enjoy!

eric@newrelic.com'

I am a Software Engineer in Portland, OR with a Masters of Engineering in Computer Science from Oregon State University. I'm a big supporter of Open Source, and have published almost all the code I've written to GitHub. I'm also an avid tea drinker, bake (scones, cookies, coffee cake, etc), and enjoy riding my Segway. View posts by .

Interested in writing for New Relic Blog? Send us a pitch!