I would like to monitor for available OS updates. Especially on all my Raspberry Pis, but there are a few more machines that need that information. I just can’t figure out how to make telegraf gather that kind of information.
Icinga2 has a nice “apt” plugin for this, but I couldn’t find anything close for telegraf.
Indeed, that is the solution I implemented yesterday.
I wrote a short perl script
#!/usr/bin/perl
use warnings;
use strict;
my $apt = `apt-get -s dist-upgrade -V`;
my $updates = 0;
my $security = 0;
foreach (split "\n", $apt) {
next if !m/^Inst/;
$updates++;
$security++ if m/Security/;
}
print "linux_updates updates=$updates","i,security=$security","i,updatestatus=",$updates==0?"0i":$security==0?"1i":"2i","\n";
updatestatus is just a boolean value indicating if any updates are available. It is just a convinience function. Much easier to check for a boolean instead for two integer values.