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!

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
    An advertisement for Honeybadger that reads 'Turn your logs into events.'

    "Splunk-like querying without having to sell my kidneys? nice"

    That’s a direct quote from someone who just saw Honeybadger Insights. It’s a bit like Papertrail or DataDog—but with just the good parts and a reasonable price tag.

    Best of all, Insights logging is available on our free tier as part of a comprehensive monitoring suite including error tracking, uptime monitoring, status pages, and more.

    Start logging for FREE
    Simple 5-minute setup — No credit card required