Announcing AptWatcher

AptWatcher is a tiny Sinatra app that notifies your Slack channel about pending apt package updates.

At Honeybadger we have been using apticron to keep on top of apt package updates for all servers. At first I had the apticron emails coming to my inbox, but at some point I decided I'd rather have them in our Slack notifications channel. Slack has a handy email app that can receive emails and post them to a channel, so I tried that. It worked, but I didn't love how the emails showed up as files, and there was all the noise of mail headers, etc., so I decided to whip up something that I would like a little more. Thus AptWatcher was born.

AptWatcher is a super simple app that I quickly threw together on a weekend to relay information about apt package updates from our servers to our Slack notifications channel. All it does it provide a HTTP endpoint that listens for a list of package names and versions that are ready to updated on a server. It compares that list to the list previously received from the server, and if any packages are found in the new list that weren't in the old list, it sends along those new packages to Slack via an incoming webhook.

That list of packages can be generated on the server by running this:

$ apt-get upgrade -s | grep ^Inst | awk '{ print $2,$3; }' | tr -d '[]'

That generates a list of packages that looks like this:

libxml2-dev 2.9.1+dfsg1-3ubuntu4.7
libxml2 2.9.1+dfsg1-3ubuntu4.7
libnl-genl-3-200 3.2.21-1ubuntu1.1
libnl-3-200 3.2.21-1ubuntu1.1

And that same list will show up in Slack when routed through AptWatcher:

Slack screenshot


Installation is as simple as clicking the Heroku button in the repo's README, and then adding a cron job to all your servers to report package changes to AptWatcher. Host records will get created automatically in AptWatcher as the reports arrive from the servers.

We use Ansible at Honeybadger to automate all the things, so I took the quick-and-dirty approach to replace apticron with AptWatcher:

$ ansible all -m apt -a 'pkg=apticron state=removed'
$ ansible all -m cron -a "name='Report pending apt changes' special_time=daily job='apt-get upgrade -s | grep ^Inst | awk \'{ print \$2,\$3; }\' | tr -d \'[]\' | curl -u user:pass --data-binary @- https://our.aptwatcher.url/report/\$(hostname) &> /dev/null'"

Once that's done, all you need to do is wait for the package reports to show up in Slack. Easy-peasy!

Honeybadger has your back when it counts.

We're the only error tracker that combines exception monitoring, uptime monitoring, and cron monitoring into a single, simple to use platform. Our mission: to tame production and make you a better, more productive developer.

Learn more
author photo

Benjamin Curtis

Ben has been developing web apps and building startups since '99, and fell in love with Ruby and Rails in 2005. Before co-founding Honeybadger, he launched a couple of his own startups: Catch the Best, to help companies manage the hiring process, and RailsKits, to help Rails developers get a jump start on their projects. Ben's role at Honeybadger ranges from bare-metal to front-end... he keeps the server lights blinking happily, builds a lot of the back-end Rails code, and dips his toes into the front-end code from time to time. When he's not working, Ben likes to hang out with his wife and kids, ride his road bike, and of course hack on open source projects. :)

More articles by Benjamin Curtis
“We've looked at a lot of error management systems. Honeybadger is head and shoulders above the rest and somehow gets better with every new release.” 
Michael Smith
Try Error Monitoring Free for 15 Days