Added high-level check spawning daemon, removed .pl suffixes
[chksht.git] / runchecks
diff --git a/runchecks b/runchecks
new file mode 100755 (executable)
index 0000000..3467c28
--- /dev/null
+++ b/runchecks
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+use strict;
+
+my $dir = shift;
+unless (-d $dir) {
+       print "$dir is not a directory\n";
+       exit 1;
+}
+
+$|++;
+
+while (1) {
+       opendir(CHECKS, $dir);
+       while (my $d = readdir(CHECKS)) {
+               next if (! -d "$dir/$d" || $d eq '.' || $d eq '..');
+               unless (-f "$dir/$d/check") {
+                       print "No check script in $dir/$d\n";
+                       next;
+               }
+               print "Running check $dir/$d: ";
+               system("runcheckdir $dir/$d");
+               my $exitstatus = $? >> 8;
+               if ($exitstatus) {
+                       print "FAILURE\n";
+               } else {
+                       print "OK\n";
+               }
+               sleep 10;
+       }
+       closedir(CHECKS);
+}