Added hung check handling
[chksht.git] / runchecks
1 #!/usr/bin/perl
2 use strict;
3
4 my $dir = shift;
5 unless ($dir) {
6         print "No directory specified\n";
7         exit 1;
8 }
9 unless (-d $dir) {
10         print "$dir is not a directory\n";
11         exit 1;
12 }
13
14 $|++;
15
16 while (1) {
17         opendir(CHECKS, $dir);
18         while (my $d = readdir(CHECKS)) {
19                 next if (! -d "$dir/$d" || $d eq '.' || $d eq '..');
20                 unless (-f "$dir/$d/check") {
21                         print "No check script in $dir/$d\n";
22                         next;
23                 }
24                 print "Running check $dir/$d: ";
25                 system("runcheckdir $dir/$d");
26                 my $exitstatus = $? >> 8;
27                 if ($exitstatus) {
28                         print "FAILURE\n";
29                 } else {
30                         print "OK\n";
31                 }
32                 sleep 10;
33         }
34         closedir(CHECKS);
35 }