Added high-level check spawning daemon, removed .pl suffixes
authorChip Black <bytex64@bytex64.net>
Mon, 18 Aug 2008 07:08:27 +0000 (02:08 -0500)
committerChip Black <bytex64@bytex64.net>
Mon, 18 Aug 2008 07:08:27 +0000 (02:08 -0500)
runcheckdir [moved from runcheckdir.pl with 100% similarity]
runchecks [new file with mode: 0755]

similarity index 100%
rename from runcheckdir.pl
rename to runcheckdir
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);
+}