prometheus-apt
#!/usr/bin/perl | |
# generates output for prometheus-node-exporter textfile collector | |
# run as cronjob. eg. | |
# 0 * * * * root /usr/local/bin/prometheus-apt > /var/lib/prometheus-textfile/prometheus-apt.prom | |
use strict; | |
use warnings; | |
use feature 'say'; | |
say "# HELP apt_update | |
# TYPE apt_update gauge"; | |
my $command = 'apt-get -o Debug::NoLocking=yes -s dist-upgrade -y'; | |
open(my $fh, '-|', $command) or die $!; | |
while (my $line = <$fh>) { | |
if ($line =~ /^Inst\s(\S+)\s(\[\S+\]\s)?\(\S+\s(.*)\s\[.*\]\)(\s\[.*\])?$/) { | |
say 'apt_update{package="', $1, '",repository="', $3, '"} 1'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment