Skip to content
Snippets Groups Projects
Commit 7344d545 authored by Yehuda Aryeh Katz's avatar Yehuda Aryeh Katz Committed by Sergey Joseph Ivanov
Browse files

Initial stab at apt monitoring

parent dd5bbfa5
No related branches found
No related tags found
No related merge requests found
package Core::Debian::Apt;
use strict;
use warnings;
use base 'Resmon::Module';
use Resmon::ExtComm qw(run_command cache_command);
=pod
=head1 NAME
Core::Ubuntu::Apt - monitor apt status
=head1 SYNOPSIS
Core::Debian::Apt {
critical_number: 500
}
=head1 DESCRIPTION
This module checks for apt packages waiting for updates.
It assumes that apt-get update is being run by another process as it likely
does not have permission to run it.
=head1 CONFIGURATION
=over
=item critical_number
Number of waiting non-security packages to return warning or critical value.
=head1 METRICS
=over
=item total
The number of packages waiting
=item security
The number of security packages waiting
=back
=cut
sub handler {
my $self = shift;
my $config = $self->{config}; # All configuration is in here
my $critical_number = $self->{critical_number} || '500';
my $apt_command = '/usr/lib/nagios/plugins/check_apt';
my $use_dist = 0;
my $output = cache_command($apt_command);
chomp $output;
$output =~ /^APT (?<severity>:OK|WARNING|CRITICAL): (?<total>[0-9.]+) packages available for (?<dist>dist-)?upgrade \((?<security>[0-9.]+) critical updates\).$/;
my $status = "OK";
if ($+{total} > $critical_number) {
$status = "WARNING";
}
if ($+{security} > 0) {
$status = "BAD";
}
return $status, {
"total" => [$+{total} , "I"],
"security" => [$+{security}, "I"],
};
};
1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment