diff --git a/perl-xCAT-2.0/xCAT/NotifHandler.pm b/perl-xCAT-2.0/xCAT/NotifHandler.pm index b8856a1b9..b31c8347f 100644 --- a/perl-xCAT-2.0/xCAT/NotifHandler.pm +++ b/perl-xCAT-2.0/xCAT/NotifHandler.pm @@ -296,16 +296,23 @@ sub notify { my ($modname, $path, $suffix) = fileparse($_, ".pm"); # print "modname=$modname, path=$path, suffix=$suffix\n"; if ($suffix =~ /.pm/) { #it is a perl module - my $pid; + my $pid; if ($pid=fork()) { } elsif (defined($pid)) { + my $fname; if (($path eq "") || ($path eq ".\/")) { #default path is /opt/xcat/lib/perl/xCAT_monitoring/ if there is no path specified - require "$::XCATROOT/lib/perl/xCAT_monitoring/".$modname.".pm"; + $fname = "$::XCATROOT/lib/perl/xCAT_monitoring/".$modname.".pm"; } else { - require $_; + $fname = $_; + } + eval {require($fname)}; + if ($@) { + print "The file $fname cannot be located or has compiling errors.\n"; + } + else { + ${"xCAT_monitoring::".$modname."::"}{processTableChanges}->($action, $tablename, $old_data, $new_data); } - ${"xCAT_monitoring::".$modname."::"}{processTableChanges}->($action, $tablename, $old_data, $new_data); exit 0; } } diff --git a/xCAT-server-2.0/lib/xcat/monitoring/monitorctrl.pm b/xCAT-server-2.0/lib/xcat/monitoring/monitorctrl.pm index 2e444f8e6..ff46c6924 100644 --- a/xCAT-server-2.0/lib/xcat/monitoring/monitorctrl.pm +++ b/xCAT-server-2.0/lib/xcat/monitoring/monitorctrl.pm @@ -370,7 +370,16 @@ sub stopMonitoring { my $file_name="$::XCATROOT/lib/perl/xCAT_monitoring/" . lc($_) . "mon.pm"; $module_name="xCAT_monitoring::" . lc($_) . "mon"; #load the module in memory - require $file_name; + eval {require($file_name)}; + if ($@) { + my @ret3=(1, "The file $file_name cannot be located or has compiling errors.\n"); + $ret{$_}=\@ret3; + next; + } + else { + my @a=($file_name, $module_name); + $PRODUCT_LIST{$pname}=\@a; + } } #stop monitoring my @ret2 = ${$module_name."::"}{stop}->(); @@ -412,7 +421,14 @@ sub stopNodeStatusMonitoring { my $file_name="$::XCATROOT/lib/perl/xCAT_monitoring/" . lc($pname) . "mon.pm"; $module_name="xCAT_monitoring::" . lc($pname) . "mon"; #load the module in memory - require $file_name; + eval {require($file_name)}; + if ($@) { + return (1, "The file $file_name cannot be located or has compiling errors.\n"); + } + else { + my @a=($file_name, $module_name); + $PRODUCT_LIST{$pname}=\@a; + } } my @ret2 = ${$module_name."::"}{stopNodeStatusMon}->(); @@ -702,10 +718,14 @@ sub refreshProductList { $file_name="$::XCATROOT/lib/perl/xCAT_monitoring/" . lc($pname) . "mon.pm"; $module_name="xCAT_monitoring::" . lc($pname) . "mon"; #load the module in memory - require $file_name; - - my @a=($file_name, $module_name); - $PRODUCT_LIST{$pname}=\@a; + eval {require($file_name)}; + if ($@) { + print "The file $file_name cannot be located or has compiling errors.\n"; + } + else { + my @a=($file_name, $module_name); + $PRODUCT_LIST{$pname}=\@a; + } } } } diff --git a/xCAT-server-2.0/lib/xcat/monitoring/xcatmon.pm b/xCAT-server-2.0/lib/xcat/monitoring/xcatmon.pm index f53067e2b..270b874a8 100644 --- a/xCAT-server-2.0/lib/xcat/monitoring/xcatmon.pm +++ b/xCAT-server-2.0/lib/xcat/monitoring/xcatmon.pm @@ -3,7 +3,7 @@ package xCAT_monitoring::xcatmon; BEGIN { - $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; } use lib "$::XCATROOT/lib/perl"; #use xCAT::NodeRange;