Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 103 lines (90 sloc) 1.73 KB
#!/usr/bin/perl
use warnings;
use strict;
my $search_home = "/home/search";
if (defined $ENV{'SEARCH_HOME'}) {
$search_home = $ENV{'SEARCH_HOME'};
}
my $dir = "$search_home/indexdata";
if (! chdir $dir)
{
print "UNKNOWN: chdir $dir: $!\n";
exit 3;
}
my @indexes = qw(
area_index
artist_index
annotation_index
releasegroup_index
release_index
recording_index
place_index
cdstub_index
freedb_index
label_index
tag_index
work_index
editor_index
instrument_index
series_index
event_index
);
my @ok;
my @warnings;
my @errors;
for my $i (@indexes)
{
if (!stat($i))
{
push @errors, "stat $i: $!";
next;
}
if ($i eq "freedb_index")
{
# units: days
my ($warn, $crit) = (35, 40);
my $age = -M(_);
my $s = ($age >= $crit ? 2 : $age >= $warn ? 1 : 0);
my $arr = (\@ok, \@warnings, \@errors)[$s];
push @$arr, sprintf "%s is %.1f days old", $i, $age;
}
elsif ($i eq "recording_index")
{
# units: hours
my ($warn, $crit) = (26, 30);
my $age = 24 * -M(_);
my $s = ($age >= $crit ? 2 : $age >= $warn ? 1 : 0);
my $arr = (\@ok, \@warnings, \@errors)[$s];
push @$arr, sprintf "%s is %.1f hours old", $i, $age;
}
else
{
# units: hours
my ($warn, $crit) = (7, 9);
my $age = 24 * -M(_);
my $s = ($age >= $crit ? 2 : $age >= $warn ? 1 : 0);
my $arr = (\@ok, \@warnings, \@errors)[$s];
push @$arr, sprintf "%s is %.1f hours old", $i, $age;
}
}
if (@errors)
{
print "CRITICAL: " . join(", ", @errors);
printf " (WARNING: %s)", join ", ", @warnings if @warnings;
printf " (OK: %s)", join ", ", @ok if @ok;
print "\n";
exit 2;
}
if (@warnings)
{
print "WARNING: " . join(", ", @warnings);
printf " (OK: %s)", join ", ", @ok if @ok;
print "\n";
exit 1;
}
{
print "OK: " . join(", ", @ok);
print "\n";
exit 0;
}
# eof
You can’t perform that action at this time.