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

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!

What to do next:
  1. Try Honeybadger for FREE
    Honeybadger helps you find and fix errors before your users can even report them. Get set up in minutes and check monitoring off your to-do list.
    Start free trial
    Easy 5-minute setup — No credit card required
  2. Get the Honeybadger newsletter
    Each month we share news, best practices, and stories from the DevOps & monitoring community—exclusively for developers like you.
    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
    Stop wasting time manually checking logs for errors!

    Try the only application health monitoring tool that allows you to track application errors, uptime, and cron jobs in one simple platform.

    • Know when critical errors occur, and which customers are affected.
    • Respond instantly when your systems go down.
    • Improve the health of your systems over time.
    • Fix problems before your customers can report them!

    As developers ourselves, we hated wasting time tracking down errors—so we built the system we always wanted.

    Honeybadger tracks everything you need and nothing you don't, creating one simple solution to keep your application running and error free so you can do what you do best—release new code. Try it free and see for yourself.

    Start free trial
    Simple 5-minute setup — No credit card required

    Learn more

    "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, Cofounder & CTO of YvesBlue

    Honeybadger is trusted by top companies like: