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

Fixed for older perl version

parent 7344d545
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ Core::Ubuntu::Apt - monitor apt status
=head1 SYNOPSIS
Core::Debian::Apt {
critical_number: 500
packages: noop
}
=head1 DESCRIPTION
......@@ -52,28 +52,31 @@ The number of security packages waiting
sub handler {
my $self = shift;
my $config = $self->{config}; # All configuration is in here
my $critical_number = $self->{critical_number} || '500';
my $critical_number = 500;
my $apt_command = '/usr/lib/nagios/plugins/check_apt';
my $use_dist = 0;
my $output = cache_command($apt_command);
my $output = run_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 ($a, $total, $security) =
$output =~ /APT (OK|WARNING|CRITICAL): ([0-9.]+) packages available for upgrade \(([0-9.]+) critical updates\)./;
my $status = "OK";
if ($+{total} > $critical_number) {
if ($total > $critical_number) {
$status = "WARNING";
}
if ($+{security} > 0) {
if ($security > 0) {
$status = "BAD";
}
return $status, {
"total" => [$+{total} , "I"],
"security" => [$+{security}, "I"],
return {
"severity" => [$status , "s"],
"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