From df1d6c601bb8d9e8f5929a887fe17e1ecd13c8bc Mon Sep 17 00:00:00 2001 From: linggao Date: Thu, 6 Mar 2008 17:07:38 +0000 Subject: [PATCH] remove the input parameters for start() and startNodeStatusMon() functions from the monitoring infrastructure. This is for performance because some plug-ins do not need the info. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@710 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-rmc/plugin/rmcmon.pm | 19 +++---------- .../lib/xcat/monitoring/monitorctrl.pm | 14 ++-------- .../xcat/monitoring/samples/templatemon.pm | 28 +++++++------------ .../lib/xcat/monitoring/snmpmon.pm | 10 ++----- .../lib/xcat/monitoring/xcatmon.pm | 10 ++----- 5 files changed, 20 insertions(+), 61 deletions(-) diff --git a/xCAT-rmc/plugin/rmcmon.pm b/xCAT-rmc/plugin/rmcmon.pm index 22e79a59e..8d637be6f 100644 --- a/xCAT-rmc/plugin/rmcmon.pm +++ b/xCAT-rmc/plugin/rmcmon.pm @@ -11,6 +11,7 @@ use Sys::Hostname; use Socket; use xCAT::Utils; use xCAT::GlobalDef; +use xCAT_monitoring::monitorctrl; #print "xCAT_monitoring::rmcmon loaded\n"; 1; @@ -44,10 +45,7 @@ use xCAT::GlobalDef; monitored by RMC are in sync with the nodes currently in the xCAT cluster. Arguments: - 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']...], ...} + None. Returns: (return code, message) =cut @@ -55,13 +53,7 @@ use xCAT::GlobalDef; sub start { print "rmcmon::start called\n"; - $noderef=shift; - if ($noderef =~ /xCAT_monitoring::rmcmon/) { - $noderef=shift; - } - - #TODO: get a list of monservers + nodes and compare them with RMC. remove/add - # if necessary. + my $noderef=xCAT_monitoring::monitorctrl->getMonHierarchy(); #assume the server is the current node. #check if rsct is installed and running @@ -237,10 +229,7 @@ sub supportNodeStatusMon { to monitor the node status changes. Arguments: - 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']...], ...} + None. Returns: (return code, message) diff --git a/xCAT-server-2.0/lib/xcat/monitoring/monitorctrl.pm b/xCAT-server-2.0/lib/xcat/monitoring/monitorctrl.pm index 2e7c0e787..23187d972 100644 --- a/xCAT-server-2.0/lib/xcat/monitoring/monitorctrl.pm +++ b/xCAT-server-2.0/lib/xcat/monitoring/monitorctrl.pm @@ -327,16 +327,6 @@ sub startMonitoring { @product_names=keys(%PRODUCT_LIST); } - my $monservers; - if (@product_names > 0) { - #get a list of monitoring servers and the nodes they are responsible for monitoring. - $monservers=getMonHierarchy(); - #foreach (keys(%$monservers)) { - # print " monitoring server: $_\n"; - # my $mon_nodes=$monservers->{$_}; - # print " nodes: @$mon_nodes\n"; - #} - } my %ret=(); foreach(@product_names) { @@ -346,7 +336,7 @@ sub startMonitoring { undef $SIG{CHLD}; #initialize and start monitoring - my @ret1 = ${$module_name."::"}{start}->($monservers); + my @ret1 = ${$module_name."::"}{start}->(); $ret{$_}=\@ret1; } else { $ret{$_}=[1, "Monitoring plug-in module $_ is not registered."]; @@ -388,7 +378,7 @@ sub startNodeStatusMonitoring { # 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}->(); return @ret2; } else { 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 9f2415cfc..620f83404 100644 --- a/xCAT-server-2.0/lib/xcat/monitoring/samples/templatemon.pm +++ b/xCAT-server-2.0/lib/xcat/monitoring/samples/templatemon.pm @@ -1,11 +1,14 @@ #!/usr/bin/env perl # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html + package xCAT_monitoring::templatemon; +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; -#use xCAT::NodeRange; -#use Socket; -#use xCAT::Utils; - +use xCAT_monitoring::monitorctrl; 1; #------------------------------------------------------------------------------- @@ -32,22 +35,15 @@ package xCAT_monitoring::templatemon; monitored by the product are in sync with the nodes currently in the xCAT cluster. Arguments: - 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']...], ...} + None. Returns: (return code, message) =cut #-------------------------------------------------------------------------------- sub start { - my $monservers=shift; - if ($monservers =~ /xCAT_monitoring::templatemon/) { - $monservers=shift; - } + my $monservers=xCAT_monitoring::monitorctrl->getMonHierarchy(); #demo how you can parse the input. you may commnet it out. - my $monservers=shift; foreach (keys(%$monservers)) { print " monitoring server: $_\n"; my $mon_nodes=$monservers->{$_}; @@ -120,13 +116,9 @@ sub supportNodeStatusMon { =cut #-------------------------------------------------------------------------------- sub startNodeStatusMon { - my $monservers=shift; - if ($monservers =~ /xCAT_monitoring::templatemon/) { - $monservers=shift; - } + my $monservers=xCAT_monitoring::monitorctrl->getMonHierarchy(); #demo how you can parse the input. you may commnet it out. - my $monservers=shift; foreach (keys(%$monservers)) { print " monitoring server: $_\n"; my $mon_nodes=$monservers->{$_}; diff --git a/xCAT-server-2.0/lib/xcat/monitoring/snmpmon.pm b/xCAT-server-2.0/lib/xcat/monitoring/snmpmon.pm index a96733ed7..04da624b8 100644 --- a/xCAT-server-2.0/lib/xcat/monitoring/snmpmon.pm +++ b/xCAT-server-2.0/lib/xcat/monitoring/snmpmon.pm @@ -28,10 +28,7 @@ print "xCAT_monitoring::snmpmon loaded\n"; This function gets called by the monitorctrl module when xcatd starts. Arguments: - 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']...], ...} + None. Returns: (return code, message) =cut @@ -227,10 +224,7 @@ sub supportNodeStatusMon { to xCAT. SNMP does not have this support. Arguments: - 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']...], ...} + None. Returns: (return code, message) diff --git a/xCAT-server-2.0/lib/xcat/monitoring/xcatmon.pm b/xCAT-server-2.0/lib/xcat/monitoring/xcatmon.pm index 7bfbd235d..bb287f02c 100644 --- a/xCAT-server-2.0/lib/xcat/monitoring/xcatmon.pm +++ b/xCAT-server-2.0/lib/xcat/monitoring/xcatmon.pm @@ -27,10 +27,7 @@ use Sys::Hostname; This function gets called by the monitorctrl module when xcatd starts. Arguments: - 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']...], ...} + None. Returns: (return code, message) =cut @@ -85,10 +82,7 @@ sub supportNodeStatusMon { the product to start monitoring the node status and feed them back to xCAT. Arguments: - 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']...], ...} + None. Returns: (return code, message)