enhance postscrit perfomance when getting monitoring variables. defect 3605
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@16704 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
b6e87461db
commit
0afc9b9d9d
@ -864,6 +864,8 @@ sub getNodeID {
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 getLocalNodeID
|
||||
This function goes to RMC and gets the nodeid for the local host.
|
||||
@ -1415,34 +1417,53 @@ sub getDescription {
|
||||
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.
|
||||
pointet to a arry of nodes
|
||||
Returns:
|
||||
none
|
||||
pointer to a 2-level hash. For format will as following:
|
||||
{
|
||||
'node1'=>{'NODEID'=>'123',
|
||||
'MS_NODEID'=>'456'},
|
||||
'node2'=>{'NODEID'=>'789',
|
||||
''MS_NODEID'=>'0AB'}
|
||||
}
|
||||
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getNodeConfData {
|
||||
my $ref_ret;
|
||||
#check if rsct is installed or not
|
||||
if (! -e "/usr/bin/lsrsrc") {
|
||||
return;
|
||||
return $ref_ret;
|
||||
}
|
||||
|
||||
my $node=shift;
|
||||
if ($node =~ /xCAT_monitoring::rmcmon/) {
|
||||
$node=shift;
|
||||
my $noderef=shift;
|
||||
if ($noderef =~ /xCAT_monitoring::rmcmon/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
my $ref_ret=shift;
|
||||
my $tab=xCAT::Table->new("mac", -create =>0);
|
||||
my $machash=$tab->getNodesAttribs($noderef, ['mac']);
|
||||
$tab->close();
|
||||
|
||||
#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;
|
||||
|
||||
foreach my $node (@$noderef) {
|
||||
#get node ids for RMC monitoring
|
||||
if ($machash && defined($machash->{$node}) && defined($machash->{$node}->[0])) {
|
||||
my $mac=$machash->{$node}->[0]->{'mac'};
|
||||
if ($mac) {
|
||||
$mac =~ s/\|.*//g; #use the first mac
|
||||
$mac =~ s/\!.*//g; #remove the hostname
|
||||
$mac =~ s/://g; #remove :
|
||||
$mac = "EA" . $mac . "EA";
|
||||
$ref_ret->{$node}->{NODEID}=$mac;
|
||||
}
|
||||
}
|
||||
|
||||
if (defined($ms_nodeid)) {
|
||||
$ref_ret->{$node}->{MS_NODEID}=$ms_nodeid;
|
||||
}
|
||||
}
|
||||
return;
|
||||
return $ref_ret;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
|
@ -325,6 +325,9 @@ sub makescript {
|
||||
$t_inc =~ s/#SITE_TABLE_ALL_ATTRIBS_EXPORT#/$allattribsfromsitetable/eg;
|
||||
$t_inc =~ s/#AIX_ROOT_PW_VARS_EXPORT#/$aixrootpasswdvars/eg;
|
||||
$t_inc =~ s/tabdump\(([\w]+)\)/tabdump($1)/eg;
|
||||
|
||||
my $monhash=getMonItems($nodes);
|
||||
#print "getMonItems get called " . Dumper($monhash) . "\n";
|
||||
|
||||
foreach my $n (@$nodes ) {
|
||||
$node = $n;
|
||||
@ -387,8 +390,13 @@ sub makescript {
|
||||
## get monitoring server and other configuration data for monitoring setup on nodes
|
||||
# for #MONITORING_VARS_EXPORT#
|
||||
my $mon_vars;
|
||||
$mon_vars = getMonItems($node);
|
||||
|
||||
if ($monhash && exists($monhash->{$node})) {
|
||||
my $mon_conf=$monhash->{$node};
|
||||
foreach (keys(%$mon_conf)) {
|
||||
$mon_vars .= "$_='" . $mon_conf->{$_} . "'\n";
|
||||
$mon_vars .= "export $_\n";
|
||||
}
|
||||
}
|
||||
|
||||
#print "nodesetstate:$nodesetstate\n";
|
||||
## OSPKGDIR export
|
||||
@ -655,21 +663,15 @@ sub getVlanItems
|
||||
|
||||
sub getMonItems
|
||||
{
|
||||
|
||||
my $node = shift;
|
||||
my $result;
|
||||
my $nodes = shift;
|
||||
|
||||
#get monitoring server and other configuration data for monitoring setup on nodes
|
||||
my %mon_conf = xCAT_monitoring::monitorctrl->getNodeConfData($node);
|
||||
foreach (keys(%mon_conf))
|
||||
{
|
||||
$result .= "$_='" . $mon_conf{$_} . "'\n";
|
||||
$result .= "export $_\n";
|
||||
my $mon_conf = xCAT_monitoring::monitorctrl->getNodeConfData($nodes);
|
||||
|
||||
if(ref($mon_conf) eq "ARRAY") {
|
||||
$mon_conf={};
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $result;
|
||||
return $mon_conf;
|
||||
}
|
||||
|
||||
sub getImage
|
||||
|
@ -95,6 +95,7 @@ sub start {
|
||||
elsif (defined($pid)) { #child process
|
||||
my $progname = \$0;
|
||||
$$progname = "xcatd: monitoring";
|
||||
|
||||
my $localhostname=hostname();
|
||||
|
||||
if ($isMonServer) { #only start monitoring on monservers.
|
||||
@ -1365,60 +1366,88 @@ sub deconfig {
|
||||
These data-value pairs will be used as environmental variables
|
||||
on the given node.
|
||||
Arguments:
|
||||
node
|
||||
noderef -- a pointer to an array of nodes.
|
||||
Returns:
|
||||
ret a hash with enviromental variable name as the key.
|
||||
ret: pointer to a 2-level hash like this:
|
||||
{
|
||||
'node1'=>{'env1'=>'value1',
|
||||
'env2'=>'value2'},
|
||||
'node2'=>{'env1'=>'value3',
|
||||
'env2'=>'value4'}
|
||||
}
|
||||
|
||||
or a pointer to array if there is an error. [error code, error message]
|
||||
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getNodeConfData {
|
||||
my $node=shift;
|
||||
if ($node =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$node=shift;
|
||||
}
|
||||
|
||||
my %ret=();
|
||||
#get monitoring server
|
||||
my $pHash=xCAT_monitoring::monitorctrl->getNodeMonServerPair([$node], 0);
|
||||
if (ref($pHash) eq 'ARRAY') {
|
||||
xCAT::MsgUtils->message('S', "[mon]: getPostScripts: " . $pHash->[1]);
|
||||
return %ret;
|
||||
}
|
||||
|
||||
my @pair_array=split(':', $pHash->{$node});
|
||||
my $monserver=$pair_array[0];
|
||||
if ($monserver eq 'noservicenode') { $monserver=hostname(); }
|
||||
$ret{MONSERVER}=$monserver;
|
||||
$ret{MONMASTER}=$pair_array[1];
|
||||
|
||||
#get all the module names from monitoring table
|
||||
my %names=();
|
||||
my $table=xCAT::Table->new("monitoring", -create =>1);
|
||||
if ($table) {
|
||||
my $tmp1=$table->getAllEntries("all");
|
||||
if (defined($tmp1) && (@$tmp1 > 0)) {
|
||||
foreach(@$tmp1) { $names{$_->{name}}=1; }
|
||||
my $noderef=shift;
|
||||
if ($noderef =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
} else {
|
||||
xCAT::MsgUtils->message('S', "[mon]: getPostScripts for node $node: cannot open monitoring table.\n");
|
||||
return %ret;
|
||||
}
|
||||
|
||||
|
||||
#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 (!$@) {
|
||||
no strict "refs";
|
||||
if (defined(${$module_name."::"}{getNodeConfData})) {
|
||||
${$module_name."::"}{getNodeConfData}->($node, \%ret);
|
||||
}
|
||||
my $nodes;
|
||||
if(ref($noderef) eq "ARRAY") {
|
||||
$nodes=$noderef;
|
||||
} else {
|
||||
$nodes=[$noderef];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return %ret;
|
||||
my $ret;
|
||||
#get monitoring server
|
||||
my $pHash=xCAT_monitoring::monitorctrl->getNodeMonServerPair($nodes, 0);
|
||||
if (ref($pHash) eq 'ARRAY') {
|
||||
xCAT::MsgUtils->message('S', "[mon]: getPostScripts: " . $pHash->[1]);
|
||||
return [1, $pHash->[1]];
|
||||
}
|
||||
|
||||
my $hostname=hostname();
|
||||
foreach my $node (@$nodes) {
|
||||
my @pair_array=split(':', $pHash->{$node});
|
||||
my $monserver=$pair_array[0];
|
||||
if ($monserver eq 'noservicenode') { $monserver=$hostname; }
|
||||
$ret->{$node}->{MONSERVER}=$monserver;
|
||||
$ret->{$node}->{MONMASTER}=$pair_array[1];
|
||||
}
|
||||
|
||||
#get all the module names from monitoring table
|
||||
my %names=();
|
||||
my $table=xCAT::Table->new("monitoring", -create =>1);
|
||||
if ($table) {
|
||||
my $tmp1=$table->getAllEntries("all");
|
||||
if (defined($tmp1) && (@$tmp1 > 0)) {
|
||||
foreach(@$tmp1) { $names{$_->{name}}=1; }
|
||||
}
|
||||
} else {
|
||||
xCAT::MsgUtils->message('S', "[mon]: getPostScripts. Cannot open monitoring table.\n");
|
||||
return [1, "Cannot open monitoring table."];
|
||||
}
|
||||
|
||||
|
||||
#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 (!$@) {
|
||||
no strict "refs";
|
||||
if (defined(${$module_name."::"}{getNodeConfData})) {
|
||||
my $ref_ret=${$module_name."::"}{getNodeConfData}->($nodes);
|
||||
if ($ref_ret) {
|
||||
foreach my $node (keys %$ref_ret) {
|
||||
my $data=$ref_ret->{$node};
|
||||
my $olddata=$ret->{$node};
|
||||
my %newhash=(%$olddata,%$data);
|
||||
$ret->{$node}=\%newhash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
|
@ -437,22 +437,29 @@ sub getPostscripts {
|
||||
the postscripts are invoked. It gets a list of environmental variables for
|
||||
the postscripts.
|
||||
Arguments:
|
||||
node the node being deployed/installed.
|
||||
pointer to a hash that will take the data.
|
||||
pointet to a arry of nodes being deployed.
|
||||
Returns:
|
||||
none
|
||||
ret: pointer to a 2-level hash like this:
|
||||
{
|
||||
'node1'=>{'env1'=>'value1',
|
||||
'env2'=>'value2'},
|
||||
'node2'=>{'env1'=>'value3',
|
||||
'env2'=>'value4'}
|
||||
}
|
||||
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getNodeConfData {
|
||||
my $node=shift;
|
||||
if ($node =~ /xCAT_monitoring::templatemon/) {
|
||||
$node=shift;
|
||||
}
|
||||
my $ref_ret=shift;
|
||||
|
||||
#sample
|
||||
$ref_ret->{MY_ENV1}="abcde";
|
||||
$ref_ret->{MY_ENV2}="abcde2";
|
||||
|
||||
return;
|
||||
my $noderef=shift;
|
||||
if ($noderef =~ /xCAT_monitoring::templatemon/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
|
||||
#sample
|
||||
my $ref_ret;
|
||||
foreach my $node (@$noderef) {
|
||||
$ref_ret->{$node}->{MY_ENV1}="abcde";
|
||||
$ref_ret->{$node}->{MY_ENV2}="abcde2";
|
||||
}
|
||||
return $ref_ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user