fix monitoring infrastureture to take a pair of hostnames in noderes.monserver
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1424 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
cf40984152
commit
4638351ddd
@ -327,7 +327,7 @@ sub startMonitoring {
|
||||
if (@product_names == 0) {
|
||||
@product_names=keys(%PRODUCT_LIST);
|
||||
}
|
||||
|
||||
#print "product_names=@product_names\n";
|
||||
|
||||
my %ret=();
|
||||
foreach(@product_names) {
|
||||
@ -621,8 +621,9 @@ sub processNodelistTableChanges {
|
||||
foreach(@hostinfo) {$iphash{$_}=1;}
|
||||
|
||||
foreach (keys(%$hierarchy)) {
|
||||
my $svname=$_;
|
||||
my $mon_nodes=$hierarchy->{$svname};
|
||||
my @server_pair=split(',', $_);
|
||||
my $svname=$server_pair[0];
|
||||
my $mon_nodes=$hierarchy->{$_};
|
||||
if (($iphash{$svname}) || ($svname eq "noservicenode")) { #this is for ms
|
||||
#call each plug-in to add the nodes into the monitoring domain
|
||||
foreach(keys(%PRODUCT_LIST)) {
|
||||
@ -638,8 +639,8 @@ sub processNodelistTableChanges {
|
||||
push(@noderange, $nodetemp->[0]);
|
||||
}
|
||||
my $cmd;
|
||||
if ($action eq "a") { $cmd="psh --nonodecheck $svname XCATBYPASS=Y monaddnode " . join(',', @noderange); }
|
||||
else { $cmd="psh --nonodecheck $svname XCATBYPASS=Y monrmnode " . join(',', @noderange); }
|
||||
if ($action eq "a") { $cmd="psh --nonodecheck $svname monaddnode --local " . join(',', @noderange); }
|
||||
else { $cmd="psh --nonodecheck $svname monrmnode --local " . join(',', @noderange); }
|
||||
#print "cmd=$cmd\n";
|
||||
my $result=`$cmd 2>&1`;
|
||||
#print "result=$result\n";
|
||||
@ -906,6 +907,48 @@ sub getPluginSettings {
|
||||
return %settings;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 getNodeMonServerPair
|
||||
It gets the monserver and monmaster for a given node.
|
||||
Arguments:
|
||||
node.
|
||||
Returns:
|
||||
"monserver,monmaser" First one is the monitoring service node ip/hostname
|
||||
that faces the mn and the second one is the monitoring service node ip/hostname
|
||||
that faces the cn.
|
||||
The value of the first one can be "noservicenode" meaning that there is no service node
|
||||
for that node. In this case the second one is the site master.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getNodeMonServerPair {
|
||||
my $node=shift;
|
||||
if ($node =~ /xCAT_monitoring::monitorctrl/) { $node=shift; }
|
||||
|
||||
my $monserver;
|
||||
my $monmaster;
|
||||
my $table2=xCAT::Table->new("noderes", -create =>0);
|
||||
my $pairs;
|
||||
my $tmp2=$table2->getNodeAttribs($node, ['monserver', 'servicenode', 'xcatmaster']);
|
||||
if (defined($tmp2) && ($tmp2)) {
|
||||
if ($tmp2->{monserver}) {
|
||||
$pairs=$tmp2->{monserver};
|
||||
#when there is only one hostname specified in noderes.monserver,
|
||||
#both monserver and monmaster take the same hostname.
|
||||
if ($pairs !~ /,/) { $pairs=$tmp2->{monserver}.','.$tmp2->{monserver}; }
|
||||
}
|
||||
}
|
||||
|
||||
if (!$pairs) {
|
||||
if ($tmp2->{servicenode}) { $monserver=$tmp2->{servicenode}; }
|
||||
if ($tmp2->{xcatmaster}) { $monmaster=$tmp2->{xcatmaster}; }
|
||||
if (!$monserver) { $monserver="noservicenode"; }
|
||||
if (!$monmaster) { $monmaster=xCAT::Utils->get_site_attribute('master'); }
|
||||
$pairs="$monserver,$monmaster";
|
||||
}
|
||||
#print "node=$node, pairs=$pairs\n";
|
||||
$table2->close();
|
||||
return $pairs;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 getMonHierarchy
|
||||
@ -918,7 +961,10 @@ sub getPluginSettings {
|
||||
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']...], ...}
|
||||
If there is no service node for a node, the key will be "noservicenode".
|
||||
A key is a pair of hostnames with the first one being the service node ip/hostname
|
||||
that faces the mn and the second one being the service node ip/hostname that faces the cn.
|
||||
The value of the first one can be "noservicenode" meaning that there is no service node
|
||||
for that node. In this case the second one is the site master.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getMonHierarchy {
|
||||
@ -929,7 +975,7 @@ sub getMonHierarchy {
|
||||
my @tmp1=$table->getAllAttribs(('node','status'));
|
||||
|
||||
my $table2=xCAT::Table->new("noderes", -create =>0);
|
||||
my @tmp2=$table2->getAllNodeAttribs(['node','monserver', 'servicenode']);
|
||||
my @tmp2=$table2->getAllNodeAttribs(['node','monserver', 'servicenode', 'xcatmaster']);
|
||||
my %temp_hash2=();
|
||||
foreach (@tmp2) {
|
||||
$temp_hash2{$_->{node}}=$_;
|
||||
@ -941,6 +987,7 @@ sub getMonHierarchy {
|
||||
foreach (@tmp3) {
|
||||
$temp_hash3{$_->{node}}=$_;
|
||||
}
|
||||
my $sitemaster=xCAT::Utils->get_site_attribute('master');
|
||||
|
||||
if (defined(@tmp1) && (@tmp1 > 0)) {
|
||||
foreach(@tmp1) {
|
||||
@ -954,19 +1001,34 @@ sub getMonHierarchy {
|
||||
}
|
||||
|
||||
my $monserver;
|
||||
my $monmaster;
|
||||
my $pairs;
|
||||
my $row2=$temp_hash2{$node};
|
||||
if (defined($row2) && ($row2)) {
|
||||
if ($row2->{monserver}) { $monserver=$row2->{monserver}; }
|
||||
elsif ($row2->{servicenode}) { $monserver=$row2->{servicenode}; }
|
||||
if ($row2->{monserver}) {
|
||||
$pairs=$row2->{monserver};
|
||||
#when there is only one hostname specified in noderes.monserver,
|
||||
#both monserver and monmaster take the same hostname.
|
||||
if ($pairs !~ /,/) { $pairs=$row2->{monserver}.','.$row2->{monserver}; }
|
||||
}
|
||||
}
|
||||
#print "node=$node, monserver=$monserver\n";
|
||||
if (!$monserver) { $monserver="noservicenode"; }
|
||||
if (exists($ret->{$monserver})) {
|
||||
my $pa=$ret->{$monserver};
|
||||
|
||||
if (!$pairs) {
|
||||
if ($row2->{servicenode}) { $monserver=$row2->{servicenode}; }
|
||||
if ($row2->{xcatmaster}) { $monmaster=$row2->{xcatmaster}; }
|
||||
if (!$monserver) { $monserver="noservicenode"; }
|
||||
if (!$monmaster) { $monmaster=$sitemaster; }
|
||||
$pairs="$monserver,$monmaster";
|
||||
}
|
||||
|
||||
#print "node=$node, pairs=$pairs\n";
|
||||
|
||||
if (exists($ret->{$pairs})) {
|
||||
my $pa=$ret->{$pairs};
|
||||
push(@$pa, [$node, $nodetype, $status]);
|
||||
}
|
||||
else {
|
||||
$ret->{$monserver}=[[$node, $nodetype, $status]];
|
||||
$ret->{$pairs}=[[$node, $nodetype, $status]];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -990,8 +1052,11 @@ sub getMonHierarchy {
|
||||
Returns:
|
||||
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']...], ...}
|
||||
If there is no service node for a node, the key will be "noservicenode".
|
||||
{monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...}
|
||||
A key is a pair of hostnames with the first one being the service node ip/hostname
|
||||
that faces the mn and the second one being the service node ip/hostname that faces the cn.
|
||||
The value of the first one can be "noservicenode" meaning that there is no service node
|
||||
for that node. In this case the second one is the site master.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getMonServerWithInfo {
|
||||
@ -1005,7 +1070,6 @@ sub getMonServerWithInfo {
|
||||
|
||||
#print "getMonServerWithInfo called with @in_nodes\n";
|
||||
#get all from the noderes table
|
||||
my $table2=xCAT::Table->new("noderes", -create =>0);
|
||||
my $table3=xCAT::Table->new("nodetype", -create =>0);
|
||||
|
||||
foreach (@in_nodes) {
|
||||
@ -1018,25 +1082,17 @@ sub getMonServerWithInfo {
|
||||
if ($tmp3->{nodetype}) { $nodetype=$tmp3->{nodetype}; }
|
||||
}
|
||||
|
||||
my $monserver;
|
||||
my $tmp2=$table2->getNodeAttribs($node, ['monserver', 'servicenode']);
|
||||
if (defined($tmp2) && ($tmp2)) {
|
||||
if ($tmp2->{monserver}) { $monserver=$tmp2->{monserver}; }
|
||||
elsif ($tmp2->{servicenode}) { $monserver=$tmp2->{servicenode}; }
|
||||
}
|
||||
if (!$monserver) { $monserver="noservicenode"; }
|
||||
my $pairs=getNodeMonServerPair($node);
|
||||
|
||||
|
||||
if (exists($ret->{$monserver})) {
|
||||
my $pa=$ret->{$monserver};
|
||||
if (exists($ret->{$pairs})) {
|
||||
my $pa=$ret->{$pairs};
|
||||
push(@$pa, [$node, $nodetype, $status]);
|
||||
}
|
||||
else {
|
||||
$ret->{$monserver}=[[$node, $nodetype, $status]];
|
||||
$ret->{$pairs}=[[$node, $nodetype, $status]];
|
||||
}
|
||||
}
|
||||
|
||||
$table2->close();
|
||||
$table3->close();
|
||||
return $ret;
|
||||
}
|
||||
@ -1053,8 +1109,11 @@ sub getMonServerWithInfo {
|
||||
Returns:
|
||||
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']...], ...}
|
||||
If there is no service node for a node, the key will be "noservicenode".
|
||||
{monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...}
|
||||
A key is a pair of hostnames with the first one being the service node ip/hostname
|
||||
that faces the mn and the second one being the service node ip/hostname that faces the cn.
|
||||
The value of the first one can be "noservicenode" meaning that there is no service node
|
||||
for that node. In this case the second one is the site master.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getMonServer {
|
||||
@ -1068,7 +1127,6 @@ sub getMonServer {
|
||||
my $ret={};
|
||||
#get all from nodelist table and noderes table
|
||||
my $table=xCAT::Table->new("nodelist", -create =>0);
|
||||
my $table2=xCAT::Table->new("noderes", -create =>0);
|
||||
my $table3=xCAT::Table->new("nodetype", -create =>0);
|
||||
|
||||
foreach (@in_nodes) {
|
||||
@ -1084,25 +1142,19 @@ sub getMonServer {
|
||||
if ($tmp3->{nodetype}) { $nodetype=$tmp3->{nodetype}; }
|
||||
}
|
||||
|
||||
my $monserver;
|
||||
my $tmp2=$table2->getNodeAttribs($node, ['monserver', 'servicenode']);
|
||||
if (defined($tmp2) && ($tmp2)) {
|
||||
if ($tmp2->{monserver}) { $monserver=$tmp2->{monserver}; }
|
||||
elsif ($tmp2->{servicenode}) { $monserver=$tmp2->{servicenode}; }
|
||||
}
|
||||
if (!$monserver) { $monserver="noservicenode"; }
|
||||
my $pairs=getNodeMonServerPair($node);
|
||||
|
||||
if (exists($ret->{$monserver})) {
|
||||
my $pa=$ret->{$monserver};
|
||||
|
||||
if (exists($ret->{$pairs})) {
|
||||
my $pa=$ret->{$pairs};
|
||||
push(@$pa, [$node, $nodetype, $status]);
|
||||
}
|
||||
else {
|
||||
$ret->{$monserver}=[ [$node,$nodetype, $status] ];
|
||||
$ret->{$pairs}=[[$node, $nodetype, $status]];
|
||||
}
|
||||
}
|
||||
}
|
||||
$table->close();
|
||||
$table2->close();
|
||||
$table3->close();
|
||||
return $ret;
|
||||
}
|
||||
@ -1124,6 +1176,77 @@ sub nodeStatMonName {
|
||||
return $NODESTAT_MON_NAME;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 pluginsAddNodes
|
||||
This function informs all the local active monitoring plug-ins to add the given
|
||||
nodes to their monitoring domain.
|
||||
Arguments:
|
||||
noderange a pointer to an array of node names
|
||||
Returns:
|
||||
ret a hash with plug-in name as the keys and the an arry of
|
||||
[return code, error message] as the values.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub pluginsAddNodes {
|
||||
my $noderef=shift;
|
||||
if ($noderef =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
|
||||
my %ret=();
|
||||
if (!$masterpid) { refreshProductList();}
|
||||
if (keys(%PRODUCT_LIST) ==0) { return %ret; }
|
||||
|
||||
#let all actvie modules to process it
|
||||
foreach(keys(%PRODUCT_LIST)) {
|
||||
my $aRef=$PRODUCT_LIST{$_};
|
||||
my $module_name=$aRef->[1];
|
||||
my @ret1=${$module_name."::"}{addNodes}->($noderef);
|
||||
$ret{$_}=\@ret1;
|
||||
|
||||
#for service node, the error may not be get shown, log it
|
||||
if ($ret1[0] >0) {
|
||||
xCAT::MsgUtils->message('S', "[mon]: $svname: $ret1[1]\n");
|
||||
}
|
||||
}
|
||||
|
||||
return %ret;
|
||||
}
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 pluginsRemoveNodes
|
||||
This function informs all the local active monitoring plug-ins to remove the given
|
||||
nodes to their monitoring domain.
|
||||
Arguments:
|
||||
noderange a pointer to an array of node names
|
||||
Returns:
|
||||
ret a hash with plug-in name as the keys and the an arry of
|
||||
[return code, error message] as the values.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub pluginsRemoveNodes {
|
||||
my $noderef=shift;
|
||||
if ($noderef =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
|
||||
my %ret=();
|
||||
if (!$masterpid) { refreshProductList();}
|
||||
if (keys(%PRODUCT_LIST) ==0) { return %ret; }
|
||||
|
||||
#let all actvie modules to process it
|
||||
foreach(keys(%PRODUCT_LIST)) {
|
||||
my $aRef=$PRODUCT_LIST{$_};
|
||||
my $module_name=$aRef->[1];
|
||||
my @ret1=${$module_name."::"}{removeNodes}->($noderef);
|
||||
$ret{$_}=\@ret1;
|
||||
|
||||
if (($ret1[0] >0)) {
|
||||
xCAT::MsgUtils->message('S', "[mon]: $_: $ret1[1]\n");
|
||||
}
|
||||
}
|
||||
|
||||
return %ret;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 addNodes
|
||||
@ -1132,25 +1255,31 @@ sub nodeStatMonName {
|
||||
not the localhost, the request will be sent to the conresponding service nodes.
|
||||
Arguments:
|
||||
noderange a pointer to an array of node names
|
||||
local 0 or 1, if set to 1, the nodes are only handled locally. No need
|
||||
to find their service nodes.
|
||||
Returns:
|
||||
ret a hash with plug-in name as the keys and the an arry of
|
||||
[return code, error message] as the values.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub addNodes {
|
||||
my %ret=();
|
||||
if (!$masterpid) { refreshProductList();}
|
||||
if (keys(%PRODUCT_LIST) ==0) { return %ret; }
|
||||
|
||||
my $p_input=shift;
|
||||
if ($p_input =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$p_input=shift;
|
||||
}
|
||||
my $handle_local=shift;
|
||||
|
||||
my %ret=();
|
||||
|
||||
|
||||
my @nodenames=@$p_input;
|
||||
if (@nodenames == 0) { return %ret; }
|
||||
#print "nodenames=@nodenames\n";
|
||||
|
||||
if ($handle_local) {
|
||||
return pluginsAddNodes($p_input);
|
||||
}
|
||||
|
||||
my $isSV=xCAT::Utils->isServiceNode();
|
||||
my @hostinfo=xCAT::Utils->determinehostname();
|
||||
%iphash=();
|
||||
@ -1160,37 +1289,34 @@ sub addNodes {
|
||||
my @mon_servers=keys(%$hierachy);
|
||||
|
||||
foreach (@mon_servers) {
|
||||
my $svname=$_;
|
||||
my $mon_nodes=$hierachy->{$svname};
|
||||
#service node come in pairs, the first one is the monserver adapter that facing the mn,
|
||||
# the second one is facing the cn. we use the first one here
|
||||
my @server_pair=split(',', $_);
|
||||
my $svname=$server_pair[0];
|
||||
my $mon_nodes=$hierachy->{$_};
|
||||
if ($iphash{$_}) {
|
||||
#let all actvie modules to process it
|
||||
foreach(keys(%PRODUCT_LIST)) {
|
||||
my $aRef=$PRODUCT_LIST{$_};
|
||||
my $module_name=$aRef->[1];
|
||||
my @ret1=${$module_name."::"}{addNodes}->($mon_nodes);
|
||||
$ret{$svname}=\@ret1;
|
||||
|
||||
#for service node, the error may not be get shown, log it
|
||||
if (($isSV) && ($ret1[0] >0)) {
|
||||
xCAT::MsgUtils->message('S', "[mon]: $svname: $ret1[1]\n");
|
||||
}
|
||||
my %ret1=pluginsAddNodes($mon_nodes);
|
||||
my @ret2=();
|
||||
foreach(keys(%ret1)) {
|
||||
push(@ret2, "$_ ".$ret1{$_}."\n");
|
||||
}
|
||||
$ret{$svname}=\@ret2;
|
||||
} elsif (!$isSV) {
|
||||
if ($svname eq "noservicenode") {
|
||||
#let all actvie modules to process it
|
||||
foreach(keys(%PRODUCT_LIST)) {
|
||||
my $aRef=$PRODUCT_LIST{$_};
|
||||
my $module_name=$aRef->[1];
|
||||
my @ret1=${$module_name."::"}{addNodes}->($mon_nodes);
|
||||
$ret{$svname}=\@ret1;
|
||||
}
|
||||
my %ret1=pluginsAddNodes($mon_nodes);
|
||||
my @ret2=();
|
||||
foreach(keys(%ret1)) {
|
||||
push(@ret2, "$_ ".$ret1{$_}."\n");
|
||||
}
|
||||
$ret{$svname}=\@ret2;
|
||||
} else {
|
||||
#forward them to the service nodes
|
||||
my @noderange=();
|
||||
foreach my $nodetemp (@$mon_nodes) {
|
||||
push(@noderange, $nodetemp->[0]);
|
||||
}
|
||||
my $cmd="psh --nonodecheck $svname XCATBYPASS=Y monaddnode " . join(',', @noderange);
|
||||
my $cmd="psh --nonodecheck $svname monaddnode --local " . join(',', @noderange);
|
||||
my $result=`$cmd 2>&1`;
|
||||
#print "result=$result\n";
|
||||
if ($?) {
|
||||
@ -1210,23 +1336,30 @@ sub addNodes {
|
||||
not the localhost, the request will be sent to the conresponding service nodes.
|
||||
Arguments:
|
||||
noderange a pointer to an array of node names
|
||||
local 0 or 1, if set to 1, the nodes are only handled locally. No need
|
||||
to find their service nodes.
|
||||
Returns:
|
||||
ret a hash with plug-in name as the keys and the an arry of
|
||||
[return code, error message] as the values.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub removeNodes {
|
||||
my %ret=();
|
||||
if (!$masterpid) { refreshProductList();}
|
||||
if (keys(%PRODUCT_LIST) ==0) { return %ret; }
|
||||
|
||||
my $p_input=shift;
|
||||
if ($p_input =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$p_input=shift;
|
||||
}
|
||||
my $handle_local=shift;
|
||||
|
||||
my %ret=();
|
||||
|
||||
my @nodenames=@$p_input;
|
||||
if (@nodenames == 0) { return %ret; }
|
||||
#print "nodenames=@nodenames\n";
|
||||
|
||||
if ($handle_local) {
|
||||
return pluginsRemoveNodes($p_input);
|
||||
}
|
||||
|
||||
|
||||
my $isSV=xCAT::Utils->isServiceNode();
|
||||
my @hostinfo=xCAT::Utils->determinehostname();
|
||||
@ -1237,37 +1370,33 @@ sub removeNodes {
|
||||
my @mon_servers=keys(%$hierachy);
|
||||
|
||||
foreach (@mon_servers) {
|
||||
my $svname=$_;
|
||||
my $mon_nodes=$hierachy->{$svname};
|
||||
my @server_pair=split(',', $_);
|
||||
my $svname=$server_pair[0];
|
||||
my $mon_nodes=$hierachy->{$_};
|
||||
if ($iphash{$_}) {
|
||||
#let all actvie modules to process it
|
||||
foreach(keys(%PRODUCT_LIST)) {
|
||||
my $aRef=$PRODUCT_LIST{$_};
|
||||
my $module_name=$aRef->[1];
|
||||
my @ret1=${$module_name."::"}{removeNodes}->($mon_nodes);
|
||||
$ret{$svname}=\@ret1;
|
||||
|
||||
#for service node, the error may not be get shown, log it
|
||||
if (($isSV) && ($ret1[0] >0)) {
|
||||
xCAT::MsgUtils->message('S', "[mon]: $svname: $ret1[1]\n");
|
||||
}
|
||||
my %ret1=pluginsRemoveNodes($mon_nodes);
|
||||
my @ret2=();
|
||||
foreach(keys(%ret1)) {
|
||||
push(@ret2, "$_ ".$ret1{$_}."\n");
|
||||
}
|
||||
$ret{$svname}=\@ret2;
|
||||
} elsif (!$isSV) {
|
||||
if ($svname eq "noservicenode") {
|
||||
#let all actvie modules to process it
|
||||
foreach(keys(%PRODUCT_LIST)) {
|
||||
my $aRef=$PRODUCT_LIST{$_};
|
||||
my $module_name=$aRef->[1];
|
||||
my @ret1=${$module_name."::"}{removeNodes}->($mon_nodes);
|
||||
$ret{$svname}=\@ret1;
|
||||
}
|
||||
my %ret1=pluginsRemoveNodes($mon_nodes);
|
||||
my @ret2=();
|
||||
foreach(keys(%ret1)) {
|
||||
push(@ret2, "$_ ".$ret1{$_}."\n");
|
||||
}
|
||||
$ret{$svname}=\@ret2;
|
||||
} else {
|
||||
#forward them to the service nodes
|
||||
my @noderange=();
|
||||
foreach my $nodetemp (@$mon_nodes) {
|
||||
push(@noderange, $nodetemp->[0]);
|
||||
}
|
||||
my $cmd="psh --nonodecheck $svname XCATBYPASS=Y monrmnode " . join(',', @noderange);
|
||||
my $cmd="psh --nonodecheck $svname monrmnode --local " . join(',', @noderange);
|
||||
my $result=`$cmd 2>&1`;
|
||||
#print "result=$result\n";
|
||||
if ($?) {
|
||||
|
@ -9,6 +9,7 @@ use lib "$::XCATROOT/lib/perl";
|
||||
use IO::File;
|
||||
use xCAT::Utils;
|
||||
use xCAT::MsgUtils;
|
||||
use xCAT_monitoring::monitorctrl;
|
||||
|
||||
|
||||
#print "xCAT_monitoring::snmpmon loaded\n";
|
||||
@ -92,14 +93,14 @@ sub configBMC {
|
||||
|
||||
#the identification of this node
|
||||
my @hostinfo=xCAT::Utils->determinehostname();
|
||||
my $isSV=xCAT::Utils->isServiceNode();
|
||||
%iphash=();
|
||||
foreach(@hostinfo) {$iphash{$_}=1;}
|
||||
my $isSV=xCAT::Utils->isServiceNode();
|
||||
if (!$isSV) { $iphash{'noservicenode'}=1;}
|
||||
|
||||
|
||||
my %masterhash=();
|
||||
my @node_a=();
|
||||
my $nrtab = xCAT::Table->new('noderes');
|
||||
my $table=xCAT::Table->new("ipmi");
|
||||
if ($table) {
|
||||
my @tmp1=$table->getAllNodeAttribs(['node','bmc']);
|
||||
@ -108,12 +109,10 @@ sub configBMC {
|
||||
my $node=$_->{node};
|
||||
my $bmc=$_->{bmc};
|
||||
|
||||
my $monserver;
|
||||
my $tent = $nrtab->getNodeAttribs($node,['monserver', 'servicenode']);
|
||||
if ($tent) {
|
||||
if ($tent->{monserver}) { $monserver=$tent->{monserver}; }
|
||||
elsif ($tent->{servicenode}) { $monserver=$tent->{servicenode}; }
|
||||
}
|
||||
my $pairs=xCAT_monitoring::monitorctrl->getNodeMonServerPair($node);
|
||||
my @a_temp=split(',',$pairs);
|
||||
my $monserver=$a_temp[0];
|
||||
my $master=$a_temp[1];
|
||||
|
||||
if ($monserver) {
|
||||
if (!$iphash{$monserver}) { next;} #skip if has sn but not localhost
|
||||
@ -124,7 +123,6 @@ sub configBMC {
|
||||
push(@node_a, $node);
|
||||
|
||||
# find the master node and add the node in the hash
|
||||
$master=xCAT::Utils->GetMasterNodeName($node); #should we use $bmc?
|
||||
if(exists($masterhash{$master})) {
|
||||
my $ref=$masterhash{$master};
|
||||
push(@$ref, $node);
|
||||
@ -133,14 +131,15 @@ sub configBMC {
|
||||
}
|
||||
$table->close();
|
||||
}
|
||||
$nrtab->close();
|
||||
|
||||
if (@node_a==0){ return ($ret_val, $ret_text);} #nothing to handle
|
||||
#print "configBMC: node_a=@node_a\n";
|
||||
|
||||
#now doing the real thing: enable PEF alert policy table
|
||||
my $noderange=join(',',@node_a );
|
||||
my $actionstring="en";
|
||||
if ($action==0) {$actionstring="dis";}
|
||||
#print "XCATBYPASS=Y rspconfig $noderange alert=$actionstring\n";
|
||||
my $result = `XCATBYPASS=Y rspconfig $noderange alert=$actionstring 2>&1`;
|
||||
if ($?) {
|
||||
xCAT::MsgUtils->message('S', "[mon]: Changeing SNMP PEF policy for IPMI nodes $noderange:\n $result\n");
|
||||
@ -153,10 +152,19 @@ sub configBMC {
|
||||
my $ref2=$masterhash{$_};
|
||||
if (@$ref2==0) { next;}
|
||||
my $nr2=join(',', @$ref2);
|
||||
my $result2 = `XCATBYPASS=Y rspconfig $nr2 snmpdest=$_ 2>&1`;
|
||||
if ($?) {
|
||||
xCAT::MsgUtils->message('S', "[mon]: Changing SNMP destination for IPMI nodes $nr2:\n $result2\n");
|
||||
$ret_tex .= "Changing SNMP destination for IPMI nodes $nr2:\n $result2\n";
|
||||
my @tmp_a=xCAT::Utils::toIP($_);
|
||||
my $ptmp=$tmp_a[0];
|
||||
if ($ptmp->[0]>0) {
|
||||
xCAT::MsgUtils->message('S', "[mon]: Converting to IP: $ptmp->[1]\n");
|
||||
$ret_val=1;
|
||||
$ret_text .= "Converting to IP: $ptmp->[1]\n";
|
||||
} else {
|
||||
#print "XCATBYPASS=Y rspconfig $nr2 snmpdest=$ptmp->[1]\n";
|
||||
my $result2 = `XCATBYPASS=Y rspconfig $nr2 snmpdest=$ptmp->[1] 2>&1`;
|
||||
if ($?) {
|
||||
xCAT::MsgUtils->message('S', "[mon]: Changing SNMP destination for IPMI nodes $nr2:\n $result2\n");
|
||||
$ret_tex .= "Changing SNMP destination for IPMI nodes $nr2:\n $result2\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -184,14 +192,14 @@ sub configMPA {
|
||||
|
||||
#the identification of this node
|
||||
my @hostinfo=xCAT::Utils->determinehostname();
|
||||
my $isSV=xCAT::Utils->isServiceNode();
|
||||
%iphash=();
|
||||
foreach(@hostinfo) {$iphash{$_}=1;}
|
||||
my $isSV=xCAT::Utils->isServiceNode();
|
||||
if (!$isSV) { $iphash{'noservicenode'}=1;}
|
||||
|
||||
my %mpa_hash=();
|
||||
my %masterhash=();
|
||||
my @node_a=();
|
||||
my $nrtab = xCAT::Table->new('noderes');
|
||||
my $table=xCAT::Table->new("mp");
|
||||
if ($table) {
|
||||
my @tmp1=$table->getAllNodeAttribs(['mpa']);
|
||||
@ -203,12 +211,10 @@ sub configMPA {
|
||||
|
||||
$mpa_hash{$mpa}=1;
|
||||
|
||||
my $monserver;
|
||||
my $tent = $nrtab->getNodeAttribs($mpa,['monserver', 'servicenode']);
|
||||
if ($tent) {
|
||||
if ($tent->{monserver}) { $monserver=$tent->{monserver}; }
|
||||
elsif ($tent->{servicenode}) { $monserver=$tent->{servicenode}; }
|
||||
}
|
||||
my $pairs=xCAT_monitoring::monitorctrl->getNodeMonServerPair($mpa);
|
||||
my @a_temp=split(',',$pairs);
|
||||
my $monserver=$a_temp[0];
|
||||
my $master=$a_temp[1];
|
||||
|
||||
if ($monserver) {
|
||||
if (!$iphash{$monserver}) { next;} #skip if has sn but not localhost
|
||||
@ -219,7 +225,6 @@ sub configMPA {
|
||||
push(@node_a, $mpa);
|
||||
|
||||
# find the master node and add the node in the hash
|
||||
$master=xCAT::Utils->GetMasterNodeName($mpa); #should we use $bmc?
|
||||
if(exists($masterhash{$master})) {
|
||||
my $ref=$masterhash{$master};
|
||||
push(@$ref, $mpa);
|
||||
@ -228,15 +233,18 @@ sub configMPA {
|
||||
}
|
||||
$table->close();
|
||||
}
|
||||
$nrtab->close();
|
||||
|
||||
if (@node_a==0){ return ($ret_val, $ret_text);} #nothing to handle
|
||||
#print "configMPA: node_a=@node_a\n";
|
||||
|
||||
|
||||
#now doing the real thing: enable PEF alert policy table
|
||||
my $noderange=join(',',@node_a );
|
||||
#print "noderange=@noderange\n";
|
||||
my $actionstring="en";
|
||||
if ($action==0) {$actionstring="dis";}
|
||||
|
||||
#print "XCATBYPASS=Y rspconfig $noderange alert=$actionstring\n";
|
||||
my $result = `XCATBYPASS=Y rspconfig $noderange alert=$actionstring 2>&1`;
|
||||
if ($?) {
|
||||
xCAT::MsgUtils->message('S', "[mon]: Changeing SNMP remote alert profile for Blade Center MM $noderange:\n $result\n");
|
||||
@ -249,10 +257,19 @@ sub configMPA {
|
||||
my $ref2=$masterhash{$_};
|
||||
if (@$ref2==0) { next;}
|
||||
my $nr2=join(',', @$ref2);
|
||||
my $result2 = `XCATBYPASS=Y rspconfig $nr2 snmpdest=$_ 2>&1`;
|
||||
if ($?) {
|
||||
xCAT::MsgUtils->message('S', "[mon]: Changing SNMP destination for Blade Center MM $nr2:\n $result2\n");
|
||||
$ret_text .= "Changing SNMP destination for Blade Center MM $nr2:\n $result2\n";
|
||||
my @tmp_a=xCAT::Utils::toIP($_);
|
||||
my $ptmp=$tmp_a[0];
|
||||
if ($ptmp->[0]>0) {
|
||||
xCAT::MsgUtils->message('S', "[mon]: Converting to IP: $ptmp->[1]\n");
|
||||
$ret_val=1;
|
||||
$ret_text .= "Converting to IP: $ptmp->[1]\n";
|
||||
} else {
|
||||
#print "XCATBYPASS=Y rspconfig $nr2 snmpdest=$ptmp->[1]\n";
|
||||
my $result2 = `XCATBYPASS=Y rspconfig $nr2 snmpdest=$ptmp->[1] 2>&1`;
|
||||
if ($?) {
|
||||
xCAT::MsgUtils->message('S', "[mon]: Changing SNMP destination for Blade Center MM $nr2:\n $result2\n");
|
||||
$ret_text .= "Changing SNMP destination for Blade Center MM $nr2:\n $result2\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -520,7 +537,7 @@ sub stopNodeStatusMon {
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub addNodes {
|
||||
print "snmpmon::addNodes\n";
|
||||
#print "snmpmon::addNodes\n";
|
||||
$noderef=shift;
|
||||
if ($noderef =~ /xCAT_monitoring::snmpmon/) {
|
||||
$noderef=shift;
|
||||
|
@ -217,7 +217,8 @@ sub getMonNodesStatus {
|
||||
my @active_nodes=();
|
||||
my @unknown_nodes=();
|
||||
|
||||
my $monservers=xCAT_monitoring::monitorctrl->getMonHierarchy();
|
||||
my $hierachy=xCAT_monitoring::monitorctrl->getMonHierarchy();
|
||||
my @mon_servers=keys(%$hierachy);
|
||||
my $isSV=xCAT::Utils->isServiceNode();
|
||||
|
||||
#on a service node or on ms, get the nodes that has local host as the server node
|
||||
@ -225,10 +226,20 @@ sub getMonNodesStatus {
|
||||
my @hostinfo=xCAT::Utils->determinehostname();
|
||||
my %iphash=();
|
||||
foreach(@hostinfo) {$iphash{$_}=1;}
|
||||
foreach my $host (@hostinfo) {
|
||||
$monnodes=$monservers->{$host};
|
||||
if (($monnodes) && (@$monnodes >0)) { last;}
|
||||
}
|
||||
#if this is mn, include the ones that has no service nodes
|
||||
if (!$isSV) { $iphash{'noservicenode'}=1;}
|
||||
|
||||
|
||||
foreach(@mon_servers) {
|
||||
#service node come in pairs, the first one is the monserver adapter that facing the mn,
|
||||
# the second one is facing the cn. we use the first one here
|
||||
my @server_pair=split(',', $_);
|
||||
my $sv=$server_pair[0];
|
||||
if ($iphash{$sv}) {
|
||||
$monnodes=$hierachy->{$_};
|
||||
}
|
||||
}
|
||||
|
||||
foreach(@$monnodes) {
|
||||
my $node=$_->[0];
|
||||
my $status=$_->[2];
|
||||
@ -237,18 +248,6 @@ sub getMonNodesStatus {
|
||||
else { push(@unknown_nodes, $node);}
|
||||
}
|
||||
|
||||
#on ms, add the ones that has no service nodes
|
||||
if (!$isSV) {
|
||||
my $monnodes_ms=$monservers->{'noservicenode'};
|
||||
foreach(@$monnodes_ms) {
|
||||
my $node=$_->[0];
|
||||
my $status=$_->[2];
|
||||
if ($status eq $::STATUS_ACTIVE) { push(@active_nodes, $node);}
|
||||
elsif ($status eq $::STATUS_INACTIVE) { push(@inactive_nodes, $node);}
|
||||
else { push(@unknown_nodes, $node);}
|
||||
}
|
||||
}
|
||||
|
||||
$status{$::STATUS_ACTIVE}=\@active_nodes;
|
||||
$status{$::STATUS_INACTIVE}=\@inactive_nodes;
|
||||
$status{unknown}=\@unknown_nodes;
|
||||
|
@ -308,9 +308,13 @@ sub monstart {
|
||||
%iphash=();
|
||||
foreach(@hostinfo) {$iphash{$_}=1;}
|
||||
foreach (@mon_servers) {
|
||||
if (! $iphash{$_} && ($_ ne "noservicenode")) { #if it is not this node, meaning it is ms
|
||||
#service node come in pairs, the first one is the monserver adapter that facing the mn,
|
||||
# the second one is facing the cn. we use the first one here
|
||||
my @server_pair=split(',', $_);
|
||||
my $sv=$server_pair[0];
|
||||
if (! $iphash{$sv} && ($sv ne "noservicenode")) { #if it is not this node, meaning it is ms
|
||||
my %rsp2;
|
||||
$rsp2->{data}->[0]="sending request to $_...";
|
||||
$rsp2->{data}->[0]="sending request to $sv...";
|
||||
$callback->($rsp2);
|
||||
# my $result=`psh --nonodecheck $_ monupdate 2>1&`;
|
||||
# if ($result) {
|
||||
@ -319,7 +323,7 @@ sub monstart {
|
||||
# }
|
||||
my %req=();
|
||||
push @{$req{command}}, "monupdate";
|
||||
$req{'_xcatdest'}=$_;
|
||||
$req{'_xcatdest'}=$sv;
|
||||
$doreq->(\%req,\&take_answer);
|
||||
}
|
||||
}
|
||||
@ -454,9 +458,13 @@ sub monstop {
|
||||
%iphash=();
|
||||
foreach(@hostinfo) {$iphash{$_}=1;}
|
||||
foreach (@mon_servers) {
|
||||
if (! $iphash{$_} && ($_ ne "noservicenode")) { #if it is not this node, meaning it is ms
|
||||
#service node come in pairs, the first one is the monserver adapter that facing the mn,
|
||||
# the second one is facing the cn. we use the first one here
|
||||
my @server_pair=split(',', $_);
|
||||
my $sv=$server_pair[0];
|
||||
if (! $iphash{$sv} && ($sv ne "noservicenode")) { #if it is not this node, meaning it is ms
|
||||
my %rsp2;
|
||||
$rsp2->{data}->[0]="sending request to $_...";
|
||||
$rsp2->{data}->[0]="sending request to $sv...";
|
||||
$callback->($rsp2);
|
||||
# my $result=`psh --nonodecheck $_ monupdate 2>1&`;
|
||||
# if ($result) {
|
||||
@ -465,7 +473,7 @@ sub monstop {
|
||||
#}
|
||||
my %req=();
|
||||
push @{$req{command}}, "monupdate";
|
||||
$req{'_xcatdest'}=$_;
|
||||
$req{'_xcatdest'}=$sv;
|
||||
$doreq->(\%req,\&take_answer);
|
||||
}
|
||||
}
|
||||
@ -660,7 +668,10 @@ sub monaddnode {
|
||||
# parse the options
|
||||
if(!GetOptions(
|
||||
'h|help' => \$::HELP,
|
||||
'v|version' => \$::VERSION,))
|
||||
'v|version' => \$::VERSION,
|
||||
'local' => \$::LOCAL,)) # this flag is used internally to indicate
|
||||
# that there is no need to find the monserver for the nodes
|
||||
# just handle them on the lccal host
|
||||
{
|
||||
&monaddnode_usage;
|
||||
return;
|
||||
@ -701,7 +712,7 @@ sub monaddnode {
|
||||
return;
|
||||
}
|
||||
|
||||
my %ret=xCAT_monitoring::monitorctrl->addNodes(\@nodenames);
|
||||
my %ret=xCAT_monitoring::monitorctrl->addNodes(\@nodenames,$::LOCAL);
|
||||
|
||||
if (%ret) {
|
||||
foreach(keys(%ret)) {
|
||||
@ -755,7 +766,11 @@ sub monrmnode {
|
||||
# parse the options
|
||||
if(!GetOptions(
|
||||
'h|help' => \$::HELP,
|
||||
'v|version' => \$::VERSION,))
|
||||
'v|version' => \$::VERSION,
|
||||
'local' => \$::LOCAL,)) # this flag is used internally to indicate
|
||||
# that there is no need to find the monserver for the nodes
|
||||
# just handle them on the lccal host
|
||||
|
||||
{
|
||||
&monrmnode_usage;
|
||||
return;
|
||||
@ -790,7 +805,7 @@ sub monrmnode {
|
||||
my @nodenames=noderange($noderange, 0);
|
||||
if (@nodenames==0) { return 0;}
|
||||
|
||||
my %ret=xCAT_monitoring::monitorctrl->removeNodes(\@nodenames);
|
||||
my %ret=xCAT_monitoring::monitorctrl->removeNodes(\@nodenames, $::LOCAL);
|
||||
if (%ret) {
|
||||
foreach(keys(%ret)) {
|
||||
my $retstat=$ret{$_};
|
||||
|
@ -159,7 +159,7 @@ while ($temp=<STDIN>) {
|
||||
}
|
||||
elsif ($oid =~ /enterprises\.3183\.1\.1\.1/) { #IPMI PRTs (traps)
|
||||
$node1=$host;
|
||||
$node1 =~ s/(-(eth|man)\d+)?(\..*)?$//;
|
||||
#$node1 =~ s/(-(eth|man)\d+)?(\..*)?$//;
|
||||
|
||||
$ip1=$ip;
|
||||
$ip1 =~ /(\d+\.\d+\.\d+\.\d+)/;
|
||||
@ -177,6 +177,7 @@ while ($temp=<STDIN>) {
|
||||
}
|
||||
}
|
||||
|
||||
#print "node1=$node1\n";
|
||||
#node1 is the bmc name, we need the node that bmc connects to to call xCAT
|
||||
my $realnode;
|
||||
my $ipmitab = xCAT::Table->new('ipmi');
|
||||
@ -190,10 +191,13 @@ while ($temp=<STDIN>) {
|
||||
$ipmitab->close();
|
||||
}
|
||||
if ($realnode) {$node1=$realnode;}
|
||||
#print "node1=$node1\n";
|
||||
|
||||
|
||||
# make the vlaue into a hex array for decoding
|
||||
$value =~ s/\"//g;
|
||||
my @varray=split(/\s+/, $value);
|
||||
#print "varray=@varray\n";
|
||||
foreach (@varray) { $_=hex($_); }
|
||||
my $error = xCAT_plugin::ipmi->decodealert($trapid, $node1, @varray);
|
||||
$briefmsg .= $error;
|
||||
|
Loading…
Reference in New Issue
Block a user