Receive an email notification if the Dropbox daemon stops running

Dropbox had some service issues last night that, although were resolved pretty quickly, caused the Dropbox daemon on my web server (running CentOS) to stop. I only noticed this morning when a post I wrote and saved to Dropbox didn’t appear on the site. (My workflow involves saving posts to Dropbox that are then automatically generated into HTML by Pelican). I logged in and did some troubleshooting and found the issues from last night had caused the daemon to stop. It’s a rare occurrence for it to stop running anyway but it’d be ideal if I could be notified if it ever happens.

As a result, I wrote a quick one-line script that’s available as a Gist on GitHub to notify me via email should it ever happen again. You’ll need to have Postfix installed as well as the Dropbox CLI script in order to send mail from your server). I’ve tested it on CentOS only but it’ll work on most distributions (YMMV).

As you can see, the script just looks at the output from the status of Dropbox (which outputs “Dropbox isn’t running!” if it’s stopped). If the daemon isn’t running, it’ll send you an email with the server’s hostname and timestamp it last checked.

Add it as a cronjob (I have it running every hour) and it’ll quietly check your Dropbox daemon status.