Put monitoring conf data for nodes in Postage.pm

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1756 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
linggao 2008-06-25 02:16:26 +00:00
parent daee2e2437
commit 34c19ca896
3 changed files with 115 additions and 3 deletions

View File

@ -191,6 +191,13 @@ sub makescript {
}
push @scriptd, "export NTYPE\n";
#get monitoring server and other configuration data for monitoring setup on nodes
my %mon_conf=xCAT_monitoring::monitorctrl->getNodeConfData($node);
foreach (keys(%mon_conf)) {
push @scriptd, "$_=" . $mon_conf{$_}. "\n";
push @scriptd, "export $_\n";
}
# get the xcatdefaults entry in the postscripts table
my $et = $posttab->getAttribs({node=>"xcatdefaults"},'postscripts');
my $defscripts = $et->{'postscripts'};

View File

@ -451,6 +451,26 @@ sub getNodeID {
return undef;
}
#--------------------------------------------------------------------------------
=head3 getLocalNodeID
This function goes to RMC and gets the nodeid for the local host.
Arguments:
node
Returns:
node id for the local host.
=cut
#--------------------------------------------------------------------------------
sub getLocalNodeID {
my $node_id=`/usr/sbin/rsct/bin/lsnodeid`;
if ($?==0) {
chomp($node_id);
return $node_id;
} else {
return undef;
}
}
#--------------------------------------------------------------------------------
=head3 addNodes
This function adds the nodes into the RMC cluster.
@ -704,3 +724,39 @@ sub getDescription {
none.\n";
}
#--------------------------------------------------------------------------------
=head3 getNodeConfData
This function gets a list of configuration data that is needed by setting up
node monitoring. These data-value pairs will be used as environmental variables
on the given node.
Arguments:
node
pointer to a hash that will take the data.
Returns:
none
=cut
#--------------------------------------------------------------------------------
sub getNodeConfData {
#check if rsct is installed or not
if (! -e "/usr/bin/lsrsrc") {
return;
}
my $node=shift;
if ($node =~ /xCAT_monitoring::rmcmon/) {
$node=shift;
}
my $ref_ret=shift;
#get node ids for RMC monitoring
my $nodeid=xCAT_monitoring::rmcmon->getNodeID($node);
if (defined($nodeid)) {
$ref_ret->{NODEID}=$nodeid;
}
my $ms_nodeid=xCAT_monitoring::rmcmon->getLocalNodeID();
if (defined($ms_nodeid)) {
$ref_ret->{MS_NODEID}=$ms_nodeid;
}
return;
}

View File

@ -15,6 +15,7 @@ use xCAT::Client;
use xCAT_plugin::notification;
use xCAT_monitoring::montbhandler;
#the list stores 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], ...)
@ -1227,9 +1228,57 @@ sub removeNodes {
}
#--------------------------------------------------------------------------------
=head3 getNodeConfData
This function goes to every monitoring plug-in module and returns a list of
configuration data that is needed by setting up node monitoring.
These data-value pairs will be used as environmental variables
on the given node.
Arguments:
node
Returns:
ret a hash with enviromental variable name as the key.
=cut
#--------------------------------------------------------------------------------
sub getNodeConfData {
my $node=shift;
if ($node =~ /xCAT_monitoring::monitorctrl/) {
$node=shift;
}
%ret=();
#get monitoring server
my $pair=xCAT_monitoring::monitorctrl->getNodeMonServerPair($node);
my @pair_array=split(',', $pair);
my $monserver=$pair_array[1];
$ret{MONSERVER}=$monserver;
#get all the module names from /opt/xcat/lib/perl/XCAT_monitoring directory
my %names=();
my @plugins=glob("$::XCATROOT/lib/perl/xCAT_monitoring/*.pm");
foreach (@plugins) {
/.*\/([^\/]*).pm$/;
$names{$1}=1;
}
# remove 2 files that are not plug-ins
delete($names{monitorctrl});
delete($names{montbhandler});
#get node conf data from each plug-in module
foreach my $pname (keys(%names)) {
my $file_name="$::XCATROOT/lib/perl/xCAT_monitoring/$pname.pm";
my $module_name="xCAT_monitoring::$pname";
#load the module in memory
eval {require($file_name)};
if (!$@) {
if (defined(${$module_name."::"}{getNodeConfData})) {
${$module_name."::"}{getNodeConfData}->($node, \%ret);
}
}
}
return %ret;
}