diff --git a/perl-xCAT-2.0/xCAT/Schema.pm b/perl-xCAT-2.0/xCAT/Schema.pm index 57eb3aab4..fbe46a53e 100644 --- a/perl-xCAT-2.0/xCAT/Schema.pm +++ b/perl-xCAT-2.0/xCAT/Schema.pm @@ -93,15 +93,16 @@ mac => { }, }, monitoring => { - cols => [qw(name nodestatmon comments disable)], + cols => [qw(name nodestatmon settings comments disable)], keys => [qw(name)], required => [qw(name)], table_desc => 'Controls what external monitoring tools xCAT sets up and uses. Entries should be added and removed from this table using the provided xCAT commands startmon and stopmon.', descriptions => { name => "The name of the mornitoring plug-in module. The plug-in must be put in $ENV{XCATROOT}/lib/perl/xCAT_monitoring/. See the man page for startmon for details.", nodestatmon => 'Specifies if the monitoring plug-in is used to feed the node status to the xCAT cluster. Any one of the following values indicates "yes": y, Y, yes, Yes, YES, 1. Any other value or blank (default), indicates "no".', - comments => 'Any user-written notes.', - disable => "Set to 'yes' or '1' to comment out this row.", + settings => 'Specifies the plug-in specific settings. These setting will be used by the plug-in to customize certain entities for the plug-in or the third party monitoring software. e.g. mon_interval=10,toggle=1', + comments => 'Any user-written notes.', + disable => "Set to 'yes' or '1' to comment out this row.", }, }, mp => { @@ -1152,6 +1153,10 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs); tabentry => 'monitoring.nodestatmon', access_tabentry => 'monitoring.name=attr:name', }, + {attr_name => 'settings', + tabentry => 'monitoring.settings', + access_tabentry => 'monitoring.name=attr:name', + }, {attr_name => 'comments', tabentry => 'monitoring.comments', access_tabentry => 'monitoring.name=attr:name', diff --git a/perl-xCAT-2.0/xCAT2.0.doc b/perl-xCAT-2.0/xCAT2.0.doc index ce9f45385..9f9abd6df 100644 Binary files a/perl-xCAT-2.0/xCAT2.0.doc and b/perl-xCAT-2.0/xCAT2.0.doc differ diff --git a/perl-xCAT-2.0/xCAT2.0.pdf b/perl-xCAT-2.0/xCAT2.0.pdf index 46ac553ab..954b8c41e 100644 Binary files a/perl-xCAT-2.0/xCAT2.0.pdf and b/perl-xCAT-2.0/xCAT2.0.pdf differ diff --git a/perl-xCAT-2.0/xCAT2onAIX.doc b/perl-xCAT-2.0/xCAT2onAIX.doc index 546bc777b..03a25a209 100644 Binary files a/perl-xCAT-2.0/xCAT2onAIX.doc and b/perl-xCAT-2.0/xCAT2onAIX.doc differ diff --git a/xCAT-server-2.0/lib/xcat/monitoring/monitorctrl.pm b/xCAT-server-2.0/lib/xcat/monitoring/monitorctrl.pm index 0f4459898..a0999c50e 100644 --- a/xCAT-server-2.0/lib/xcat/monitoring/monitorctrl.pm +++ b/xCAT-server-2.0/lib/xcat/monitoring/monitorctrl.pm @@ -18,7 +18,7 @@ use xCAT_monitoring::montbhandler; #the list store the names of the monitoring plug-in and the file name and module names. #the names are stored in the "name" column of the monitoring table. -#the format is: (name=>[filename, modulename], ...) +#the format is: (name=>[filename, modulename, settings], ...) %PRODUCT_LIST; #stores the module name and the method that is used for the node status monitoring @@ -343,10 +343,11 @@ sub startMonitoring { my $aRef=$PRODUCT_LIST{$_}; if ($aRef) { my $module_name=$aRef->[1]; + my $settings=$aRef->[2]; undef $SIG{CHLD}; #initialize and start monitoring - my @ret1 = ${$module_name."::"}{start}->($monservers); + my @ret1 = ${$module_name."::"}{start}->($monservers, $settings); $ret{$_}=\@ret1; } else { $ret{$_}=[1, "Monitoring plug-in module $_ is not registered."]; @@ -383,12 +384,13 @@ sub startNodeStatusMonitoring { my $aRef=$PRODUCT_LIST{$pname}; if ($aRef) { my $module_name=$aRef->[1]; + my $settings=$aRef->[2]; undef $SIG{CHLD}; my $method = ${$module_name."::"}{supportNodeStatusMon}->(); # return value 0 means not support. 1 means yes. if ($method > 0) { #start nodes tatus monitoring - my @ret2 = ${$module_name."::"}{startNodeStatusMon}->(getMonHierarchy()); + my @ret2 = ${$module_name."::"}{startNodeStatusMon}->(getMonHierarchy(), $settings); return @ret2; } else { @@ -772,7 +774,7 @@ sub refreshProductList { #get the monitoring plug-in list from the monitoring table my $table=xCAT::Table->new("monitoring", -create =>1); if ($table) { - my @tmp1=$table->getAllAttribs(('name','nodestatmon')); + my @tmp1=$table->getAllAttribs(('name','nodestatmon', 'settings')); if (defined(@tmp1) && (@tmp1 > 0)) { foreach(@tmp1) { my $pname=$_->{name}; @@ -784,15 +786,16 @@ sub refreshProductList { } #find out the monitoring plugin file and module name for the product - $file_name="$::XCATROOT/lib/perl/xCAT_monitoring/$pname.pm"; - $module_name="xCAT_monitoring::$pname"; + my $file_name="$::XCATROOT/lib/perl/xCAT_monitoring/$pname.pm"; + my $module_name="xCAT_monitoring::$pname"; + my $settings=$_->{settings}; #load the module in memory 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); + my @a=($file_name, $module_name, $settings); $PRODUCT_LIST{$pname}=\@a; } } diff --git a/xCAT-server-2.0/lib/xcat/monitoring/samples/templatemon.pm b/xCAT-server-2.0/lib/xcat/monitoring/samples/templatemon.pm index 8aa914903..0157d82bf 100644 --- a/xCAT-server-2.0/lib/xcat/monitoring/samples/templatemon.pm +++ b/xCAT-server-2.0/lib/xcat/monitoring/samples/templatemon.pm @@ -36,6 +36,7 @@ package xCAT_monitoring::templatemon; and each value is a ref to an array of [nodes, nodetype, status] arrays monitored by the server. So the format is: {monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...} + settings -- ping-interval=x, x is in number of minutes Returns: (return code, message) =cut @@ -45,6 +46,7 @@ sub start { if ($monservers =~ /xCAT_monitoring::templatemon/) { $monservers=shift; } + my $setting=shift; #demo how you can parse the input. you may commnet it out. my $monservers=shift; @@ -114,6 +116,7 @@ sub supportNodeStatusMon { and each value is a ref to an array of [nodes, nodetype, status] arrays monitored by the server. So the format is: {monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...} + settings -- ping-interval=x, x is in number of minutes Returns: (return code, message) @@ -124,6 +127,7 @@ sub startNodeStatusMon { if ($monservers =~ /xCAT_monitoring::templatemon/) { $monservers=shift; } + my $setting=shift; #demo how you can parse the input. you may commnet it out. my $monservers=shift; diff --git a/xCAT-server-2.0/lib/xcat/monitoring/xcatmon.pm b/xCAT-server-2.0/lib/xcat/monitoring/xcatmon.pm index 2935db6b5..d903eb43d 100644 --- a/xCAT-server-2.0/lib/xcat/monitoring/xcatmon.pm +++ b/xCAT-server-2.0/lib/xcat/monitoring/xcatmon.pm @@ -30,7 +30,8 @@ use Sys::Hostname; monservers --A hash reference keyed by the monitoring server nodes and each value is a ref to an array of [nodes, nodetype, status] arrays monitored by the server. So the format is: - {monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...} + {monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...} + settings -- ping-interval=x, x is in number of minutes Returns: (return code, message) =cut @@ -89,26 +90,40 @@ sub supportNodeStatusMon { and each value is a ref to an array of [nodes, nodetype, status] arrays monitored by the server. So the format is: {monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...} + settings -- ping-interval=x, x is in number of minutes Returns: (return code, message) =cut #-------------------------------------------------------------------------------- sub startNodeStatusMon { + my $temp=shift; + if ($temp =~ /xCAT_plugin::xcatmon/) { + $temp=shift; + } + my $setting=shift; + #print "xcatmon.startNodeStatusMon\n"; #run the command first to update the status, my $cmd="$::XCATROOT/sbin/xcatnodemon"; - $output=`$cmd 2>&1`; - if ($?) { - print "xcatmon: $output\n"; + #$output=`$cmd 2>&1`; + #if ($?) { + # print "xcatmon: $output\n"; + #} + + #figure out the ping-intercal setting + my $value=3; + if ($setting) { + if ($setting =~ /ping-interval=(\d+)/) { $value= ($1>0) ? $1 : 3; } } + #create the cron job, it will run the command every 3 minutes. - my $newentry="*/3 * * * * XCATROOT=$::XCATROOT $cmd"; + my $newentry="*/$value * * * * XCATROOT=$::XCATROOT $cmd"; my ($code, $msg)=xCAT::Utils::add_cron_job($newentry); if ($code==0) { return (0, "started"); } - else { return ($code, $msg); } + else { return ($code, $msg); } } diff --git a/xCAT-server-2.0/lib/xcat/plugins/monctrlcmds.pm b/xCAT-server-2.0/lib/xcat/plugins/monctrlcmds.pm index df70b0972..46696b2ee 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/monctrlcmds.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/monctrlcmds.pm @@ -127,19 +127,21 @@ sub startmon { { my %rsp; $rsp->{data}->[0]= "Usage:"; - $rsp->{data}->[1]= " startmon name [-n|--nodestatmon]"; + $rsp->{data}->[1]= " startmon name [-n|--nodestatmon] [-s|--settings]"; $rsp->{data}->[2]= " startmon [-h|--help|-v|--version]"; $rsp->{data}->[3]= " name is the name of the monitoring plug-in to be registered and invoked."; $callback->($rsp); } @ARGV=@{$args}; + my $settings; # parse the options if(!GetOptions( 'h|help' => \$::HELP, 'v|version' => \$::VERSION, - 'n|nodestatmon' => \$::NODESTATMON)) + 'n|nodestatmon' => \$::NODESTATMON, + 's|settings=s' => \$settings)) { &startmon_usage; return; @@ -223,8 +225,12 @@ sub startmon { $nstat='Y'; } my %tb_cols=(nodestatmon=>$nstat); + if ($settings) { + $tb_cols{settings}=$settings; + } $table->setAttribs(\%key_col, \%tb_cols); - } + } + $table->close(); } my %rsp1;