For a while I've been having trouble with the path to various things 
invoked by the monitor scripts (e.g. fping).  Small changes to the 
environment, reinstalling modules, etc, would cause the external program 
to not be found.  I finally got sick of this and modified mon to allow its 
path to be set in the configuration file.

A couple of notes, it is for mon-0.99.2, and accepts any case for PATH 
(i.e. PATH, path or even PaTh - because I'd prefer to use the uppercase 
value to be consistent with the shell).  Also, if the value "$PATH" is in 
the string, it will interpolate the current path into the string before 
setting it (so you can do "PATH = $PATH:/usr/sbin") and it checks that 
each directory specified exists.

Frank Crawford

-- 
--- mon.sav     Tue Mar 26 14:20:03 2002
+++ mon Tue Mar 26 17:04:28 2002
@@ -340,6 +340,9 @@
 $SIG{TERM} = \&handle_sigterm;
 $SIG{PIPE} = 'IGNORE';
 
+# Set executable search path for children
+$ENV{'PATH'} = $CF{'PATH'} if $CF{'PATH'};
+
 #
 # load previously saved state
 #
@@ -988,6 +991,17 @@
                    $new_CF{"STARTUPALERTS_ON_RESET"} = 0;
                }
 
+           } elsif (lc($1) eq "path") {
+               my $path = $2;
+               $path =~ s/\b\$PATH\b/$ENV{'PATH'}/g;
+               foreach my $dir (split(':', $path)) {
+                   if (! -d $dir) {
+                       close (CFG);
+                       return "cf error: invalid path specified '$dir' in '$path', 
+line $line_num";
+                   }
+               }
+               $new_CF{"PATH"} = $path;
+
            } else {
                close (CFG);
                return "cf error: unknown variable '$1', line $line_num";


-- 
ac3
Suite G16, Bay 7, Locomotive Workshop   Phone:  02 9209 4600
Australian Technology Park              Fax:    02 9209 4611
Eveleigh   NSW   1430

Reply via email to