Skip to content

Commit

Permalink
Fixing error in package-yum that returns 300 when a repo is not avail…
Browse files Browse the repository at this point in the history
…able
  • Loading branch information
carsso committed Mar 18, 2016
1 parent 763e77e commit a451849
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.73.6
0.73.7
38 changes: 25 additions & 13 deletions probes/examples/packages-yum
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ if ( !$delta_update or $delta_update > 30 * 60 )

foreach my $line ( split "\n" , $fnret )
{
if ( $line =~ /^E:\s(.*)/ )
if ( $line =~ /^Error:\s(.*)/ )
{
$errorOnUpdate = 1;
push @{ detail->{'Yum-Clean'}->{'Errors'} } , $1;
}
elsif ( $line =~ /^W:\s(.*)/ )
{
$errorOnUpdate = 1;
push @{ detail->{'Yum-Clean'}->{'Warnings'} } , $1 ;
}
}

if ( $errorOnUpdate )
{
raise 200;
message "An error happened when doing yum clean. ";
}

###
Expand All @@ -56,13 +57,20 @@ if ( !$delta_update or $delta_update > 30 * 60 )
my $packagesToUpdate = {};
$fnret = `LANGUAGE=C yum --quiet --security check-update 2>&1`;
chomp $fnret;

my $update = 0;
my $securityUpdate = 0;
foreach my $line ( split "\n" , $fnret )
{
if ( my ($name,$version,$repo) = $line =~ /^(\S+)\s+(\S+)\s+(\S+)/ )
if ( $line =~ /^Error:\s(.*)/ )
{
$errorOnUpdate = 1;
push @{ detail->{'Yum-List-Security-Updates'}->{'Errors'} } , $1;
}
elsif ( my ($name,$version,$repo) = $line =~ /^(\S+)\s+(\S+)\s+(\S*)$/ )
{
detail->{'Yum-List-Security-Updates'}->{$repo} ||= [];
push @{detail->{'Yum-List-Security-Updates'}->{$repo}}, $name;
$securityUpdate++;
}
}
Expand All @@ -71,15 +79,19 @@ if ( !$delta_update or $delta_update > 30 * 60 )
if ( $errorOnUpdate )
{
raise 200;
message "An error happened when doing apt-get update. ";
message "An error happened when doing yum --security check-update. ";
}

$fnret = `LANGUAGE=C yum --quiet check-update 2>&1`;
$fnret = `LANGUAGE=C yum --quiet check-update 2>&1`;
chomp $fnret;

foreach my $line ( split "\n" , $fnret )
{
if ( my ($name,$version,$repo) = $line =~ /^(\S+)\s+(\S+)\s+(\S+)/ )
if ( $line =~ /^Error:\s(.*)/ )
{
$errorOnUpdate = 1;
push @{ detail->{'Yum-List-Updates'}->{'Errors'} } , $1;
}
elsif ( my ($name,$version,$repo) = $line =~ /^(\S+)\s+(\S+)\s+(\S*$)/ )
{
detail->{'Yum-List-Updates'}->{$repo} ||= [];
push @{detail->{'Yum-List-Updates'}->{$repo}}, $name;
Expand All @@ -90,7 +102,7 @@ if ( !$delta_update or $delta_update > 30 * 60 )
if ( $errorOnUpdate )
{
raise 200;
message "An error happened when doing apt-get update. ";
message "An error happened when doing yum check-update. ";
}

if ( $update )
Expand Down

0 comments on commit a451849

Please sign in to comment.