added synamic handling for node changes in the monitoring plug-in infrastructure. renamed the startmon to monstart, stopmon to monstop, lsmon to monls and added monaddnode and monrmnode commands
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@868 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
1b53a0cc5d
commit
b6866cc758
@ -1,18 +1,18 @@
|
||||
=head1 NAME
|
||||
|
||||
B<lsmon> - Lists monitoring plug-in modules that can be used to monitor the xCAT cluster.
|
||||
B<monls> - Lists monitoring plug-in modules that can be used to monitor the xCAT cluster.
|
||||
|
||||
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
I<lsmon [-h| --help]>
|
||||
I<monls [-h| --help]>
|
||||
|
||||
I<lsmon [-v| --version]>
|
||||
I<monls [-v| --version]>
|
||||
|
||||
I<lsmon I<name> [-d|--description]>
|
||||
I<monls I<name> [-d|--description]>
|
||||
|
||||
I<lsmon [-a|--all] [-d|--description]>
|
||||
I<monls [-a|--all] [-d|--description]>
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
@ -49,7 +49,7 @@ B<-V | -verbose> Verbose output.
|
||||
|
||||
1. To list the status of all the monitoring plug-in modules from the I<monitoring> table, enter:
|
||||
|
||||
lsmon
|
||||
monls
|
||||
|
||||
The output looks like this:
|
||||
xcatmon monitored node-status-monitored
|
||||
@ -57,7 +57,7 @@ The output looks like this:
|
||||
|
||||
2. To list the status of all the monitoring plug-in modules including the ones that are not in the monitoring table, enter
|
||||
|
||||
lsmon -a
|
||||
monls -a
|
||||
|
||||
The output looks like this:
|
||||
xcatmon monitored node-status-monitored
|
||||
@ -69,17 +69,17 @@ The output looks like this:
|
||||
|
||||
3. To list the status and the desciption for I<snmpmon> module, enter:
|
||||
|
||||
lsmon snmpmon -d
|
||||
monls snmpmon -d
|
||||
|
||||
|
||||
=head1 FILES
|
||||
|
||||
/opt/xcat/bin/lsmon
|
||||
/opt/xcat/bin/monls
|
||||
|
||||
|
||||
=head1 NOTES
|
||||
|
||||
See stopmon startmon
|
||||
See monstart monstop
|
||||
|
||||
This command is part of the xCAT software product.
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
=head1 NAME
|
||||
|
||||
B<startmon> - Starts a plug-in module to monitor the xCAT cluster.
|
||||
B<monstart> - Starts a plug-in module to monitor the xCAT cluster.
|
||||
|
||||
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
I<startmon [-h| --help]>
|
||||
I<monstart [-h| --help]>
|
||||
|
||||
I<startmon [-v| --version]>
|
||||
I<monstart [-v| --version]>
|
||||
|
||||
|
||||
I<startmon I<name> [-n|--nodestatmon] [-s|--settings settings]>
|
||||
I<monstart I<name> [-n|--nodestatmon] [-s|--settings settings]>
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
@ -49,27 +49,27 @@ B<-V | -verbose> Verbose output.
|
||||
|
||||
1. To start gangliamon plug-in module (which interacts with Ganglia monitoring software) to monitor the xCAT cluster, enter:
|
||||
|
||||
startmon gangliamon
|
||||
monstart gangliamon
|
||||
|
||||
2. To start rmcmon plug-in module (which interacts with IBM's RSCT monitoring software) to monitor the xCAT cluster and have it feed the node liveness status to xCAT's I<nodelist> table, enter:
|
||||
|
||||
startmon rmcmon -n
|
||||
monstart rmcmon -n
|
||||
|
||||
3. To start xcatmon plug-in module to feed the node liveness status to xCAT's I<nodelist> table, enter:
|
||||
|
||||
startmon rmcmon -n -s [ping-interval=2]
|
||||
monstart rmcmon -n -s [ping-interval=2]
|
||||
where 2 is the number of minutes between the pings.
|
||||
|
||||
|
||||
|
||||
=head1 FILES
|
||||
|
||||
/opt/xcat/bin/startmon
|
||||
/opt/xcat/bin/monstart
|
||||
|
||||
|
||||
=head1 NOTES
|
||||
|
||||
See stopmon lsmon
|
||||
See monstop monls
|
||||
|
||||
This command is part of the xCAT software product.
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
=head1 NAME
|
||||
|
||||
B<stopmon> - Stops a monitoring plug-in module to monitor the xCAT cluster.
|
||||
B<monstop> - Stops a monitoring plug-in module to monitor the xCAT cluster.
|
||||
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
I<stopmon [-h| --help]>
|
||||
I<monstop [-h| --help]>
|
||||
|
||||
I<stopmon [-v| --version]>
|
||||
I<monstop [-v| --version]>
|
||||
|
||||
|
||||
I<stopmon name>
|
||||
I<monstop name>
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
@ -41,7 +41,7 @@ B<-V | -verbose> Verbose output.
|
||||
|
||||
1.To stop gangliamon plug-in module (which interacts with Ganglia monitoring software) to monitor the xCAT cluster, enter:
|
||||
|
||||
stopmon gangliamon
|
||||
monstop gangliamon
|
||||
|
||||
Please note that gangliamon must have been registered in the xCAT I<monitoring> table. For a list of registered plug-in modules, use command I<tabdump monitoring>.
|
||||
|
||||
@ -49,12 +49,12 @@ Please note that gangliamon must have been registered in the xCAT I<monitoring>
|
||||
|
||||
=head1 FILES
|
||||
|
||||
/opt/xcat/bin/stopmon
|
||||
/opt/xcat/bin/monstop
|
||||
|
||||
|
||||
=head1 NOTES
|
||||
|
||||
See startmon
|
||||
See monstart monls
|
||||
|
||||
This command is part of the xCAT software product.
|
||||
|
||||
|
@ -134,10 +134,12 @@ ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/sbin/makenetworks
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/sbin/copycds
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/regnotif
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/unregnotif
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/startmon
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/stopmon
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/updatemon
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/lsmon
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/monstart
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/monstop
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/bin/monls
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/sbin/monupdate
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/sbin/monaddnode
|
||||
ln -sf ../bin/xcatclientnnr $RPM_BUILD_ROOT/%{prefix}/sbin/monrmnode
|
||||
ln -sf ../bin/xcatDBcmds $RPM_BUILD_ROOT/%{prefix}/bin/mkdef
|
||||
ln -sf ../bin/xcatDBcmds $RPM_BUILD_ROOT/%{prefix}/bin/chdef
|
||||
ln -sf ../bin/xcatDBcmds $RPM_BUILD_ROOT/%{prefix}/bin/lsdef
|
||||
|
@ -264,13 +264,11 @@ sub stopNodeStatusMon {
|
||||
=head3 addNodes
|
||||
This function adds the nodes into the RMC cluster.
|
||||
Arguments:
|
||||
nodes --nodes to be added. It is 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']...], ...}
|
||||
verbose -- verbose mode. 1 for yes, 0 for no.
|
||||
nodes --nodes to be added. It is a pointer to an array with each element
|
||||
being a ref to an array of [nodes, nodetype, status]. For example:
|
||||
[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']..]
|
||||
Returns:
|
||||
none
|
||||
(error code, error message)
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub addNodes {
|
||||
@ -283,7 +281,7 @@ sub addNodes {
|
||||
|
||||
|
||||
my $ms_host_name=hostname();
|
||||
my $mon_nodes=$noderef->{$ms_host_name};
|
||||
my $mon_nodes=$noderef;
|
||||
|
||||
my @nodes_to_add=();
|
||||
foreach(@$mon_nodes) {
|
||||
@ -316,7 +314,7 @@ sub addNodes {
|
||||
return addNodes_noChecking(@nodes_to_add);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (0, "ok");
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
@ -326,7 +324,7 @@ sub addNodes {
|
||||
Arguments:
|
||||
nodes --an array of nodes to be added.
|
||||
Returns:
|
||||
none
|
||||
(error code, error message)
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub addNodes_noChecking {
|
||||
@ -412,20 +410,18 @@ sub addNodes_noChecking {
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (0, "ok");
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 removeNodes
|
||||
This function removes the nodes from the RMC cluster.
|
||||
Arguments:
|
||||
nodes --nodes to be removed. It is 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']...], ...}
|
||||
verbose -- verbose mode. 1 for yes, 0 for no.
|
||||
nodes --nodes to be removed. It is a pointer to an array with each element
|
||||
being a ref to an array of [nodes, nodetype, status]. For example:
|
||||
[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']..]
|
||||
Returns:
|
||||
none
|
||||
(error code, error message)
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub removeNodes {
|
||||
@ -436,7 +432,7 @@ sub removeNodes {
|
||||
|
||||
#print "rmcmon::removeNodes called\n";
|
||||
my $ms_host_name=hostname();
|
||||
my $mon_nodes=$noderef->{$ms_host_name};
|
||||
my $mon_nodes=$noderef;
|
||||
|
||||
my @nodes_to_remove=();
|
||||
|
||||
@ -454,7 +450,7 @@ sub removeNodes {
|
||||
return removeNodes_noChecking(@nodes_to_remove);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (0, "ok");
|
||||
}
|
||||
|
||||
|
||||
@ -464,7 +460,7 @@ sub removeNodes {
|
||||
Arguments:
|
||||
nodes --an array of node names to be removed.
|
||||
Returns:
|
||||
none
|
||||
(error code, error message)
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub removeNodes_noChecking {
|
||||
@ -515,7 +511,7 @@ sub removeNodes_noChecking {
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (0, "ok";
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
|
@ -553,6 +553,9 @@ sub processTableChanges {
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub processNodelistTableChanges {
|
||||
#does not handle this function on a service node
|
||||
if (xCAT::Utils->isServiceNode()) { return 0;}
|
||||
|
||||
my $action=shift;
|
||||
if ($action =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$action=shift;
|
||||
@ -585,15 +588,6 @@ sub processNodelistTableChanges {
|
||||
my $status='';
|
||||
if (exists($new_data->{status})) {$status=$new_data->{status};}
|
||||
push(@nodenames, [$new_data->{node}, $status]);
|
||||
my $hierarchy=getMonServerWithInfo(\@nodenames);
|
||||
|
||||
#call each plug-in to add the nodes into the monitoring domain
|
||||
foreach(keys(%PRODUCT_LIST)) {
|
||||
my $aRef=$PRODUCT_LIST{$_};
|
||||
my $module_name=$aRef->[1];
|
||||
#print "moduel_name=$module_name\n";
|
||||
${$module_name."::"}{addNodes}->($hierarchy, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif ($action eq "d") {
|
||||
@ -613,21 +607,47 @@ sub processNodelistTableChanges {
|
||||
for (my $j=1; $j<@$old_data; ++$j) {
|
||||
push(@nodenames, [$old_data->[$j]->[$node_i], $old_data->[$j]->[$status_i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else { return 0; }
|
||||
|
||||
if (@nodenames > 0) {
|
||||
#print "monitorctrl: nodenames=@nodenames\n";
|
||||
my $hierarchy=getMonServerWithInfo(\@nodenames);
|
||||
if (@nodenames ==0) { return 0;}
|
||||
|
||||
#call each plug-in to remove the nodes into the monitoring domain
|
||||
foreach(keys(%PRODUCT_LIST)) {
|
||||
my $aRef=$PRODUCT_LIST{$_};
|
||||
my $module_name=$aRef->[1];
|
||||
${$module_name."::"}{removeNodes}->($hierarchy, 1);
|
||||
}
|
||||
print "monitorctrl: nodenames=@nodenames\n";
|
||||
my $hierarchy=getMonServerWithInfo(\@nodenames);
|
||||
|
||||
#get all possible ip and hostname for the local host
|
||||
my @hostinfo=xCAT::Utils->determinehostname();
|
||||
my %iphash=();
|
||||
foreach(@hostinfo) {$iphash{$_}=1;}
|
||||
|
||||
foreach (keys(%$hierarchy)) {
|
||||
my $svname=$_;
|
||||
my $mon_nodes=$hierarchy->{$svname};
|
||||
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)) {
|
||||
my $aRef=$PRODUCT_LIST{$_};
|
||||
my $module_name=$aRef->[1];
|
||||
#print "moduel_name=$module_name\n";
|
||||
if ($action eq "a") { ${$module_name."::"}{addNodes}->($mon_nodes);}
|
||||
else { ${$module_name."::"}{removeNodes}->($mon_nodes);} }
|
||||
} else { #this is for a service node
|
||||
#call each service node to handle it
|
||||
my @noderange=();
|
||||
foreach my $nodetemp (@$mon_nodes) {
|
||||
push(@noderange, $nodetemp->[0]);
|
||||
}
|
||||
my $cmd;
|
||||
if ($action eq "a") { $cmd="psh $svname XCATBYPASS=Y monaddnode " . join(',', @noderange); }
|
||||
else { $cmd="psh $svname XCATBYPASS=Y monrmnode " . join(',', @noderange); }
|
||||
my $result=`$cmd 2>&1`;
|
||||
if ($?) {
|
||||
xCAT::MsgUtils->message('S', "[mon]:$cmd result=$result\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -745,7 +765,7 @@ sub processNodeStatusChanges {
|
||||
}
|
||||
}
|
||||
else {
|
||||
xCAT::MsgUtils->message("E", "Could not read the nodelist table\n");
|
||||
xCAT::MsgUtils->message("S", "Could not read the nodelist table\n");
|
||||
}
|
||||
|
||||
$tab->close;
|
||||
@ -970,10 +990,14 @@ sub getMonHierarchy {
|
||||
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".
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getMonServerWithInfo {
|
||||
my $p_input=shift;
|
||||
if ($p_input =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$p_input=shift;
|
||||
}
|
||||
my @in_nodes=@$p_input;
|
||||
|
||||
my $ret={};
|
||||
@ -982,8 +1006,6 @@ sub getMonServerWithInfo {
|
||||
#get all from the noderes table
|
||||
my $table2=xCAT::Table->new("noderes", -create =>0);
|
||||
my $table3=xCAT::Table->new("nodetype", -create =>0);
|
||||
my @hostinfo=xCAT::Utils->determinehostname();
|
||||
my $host=pop(@hostinfo);
|
||||
|
||||
foreach (@in_nodes) {
|
||||
my $node=$_->[0];
|
||||
@ -995,12 +1017,13 @@ sub getMonServerWithInfo {
|
||||
if ($tmp3->{nodetype}) { $nodetype=$tmp3->{nodetype}; }
|
||||
}
|
||||
|
||||
my $monserver=$host;
|
||||
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"; }
|
||||
|
||||
|
||||
if (exists($ret->{$monserver})) {
|
||||
@ -1030,10 +1053,15 @@ sub getMonServerWithInfo {
|
||||
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".
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getMonServer {
|
||||
my $p_input=shift;
|
||||
if ($p_input =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$p_input=shift;
|
||||
}
|
||||
|
||||
my @in_nodes=@$p_input;
|
||||
|
||||
my $ret={};
|
||||
@ -1041,8 +1069,6 @@ sub getMonServer {
|
||||
my $table=xCAT::Table->new("nodelist", -create =>0);
|
||||
my $table2=xCAT::Table->new("noderes", -create =>0);
|
||||
my $table3=xCAT::Table->new("nodetype", -create =>0);
|
||||
my @hostinfo=xCAT::Utils->determinehostname();
|
||||
my $host=pop(@hostinfo);
|
||||
|
||||
foreach (@in_nodes) {
|
||||
my @tmp1=$table->getAttribs({'node'=>$_}, ('node', 'status'));
|
||||
@ -1057,12 +1083,13 @@ sub getMonServer {
|
||||
if ($tmp3->{nodetype}) { $nodetype=$tmp3->{nodetype}; }
|
||||
}
|
||||
|
||||
my $monserver=$host;
|
||||
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"; }
|
||||
|
||||
if (exists($ret->{$monserver})) {
|
||||
my $pa=$ret->{$monserver};
|
||||
@ -1097,6 +1124,152 @@ sub nodeStatMonName {
|
||||
}
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 addNodes
|
||||
This function informs all the active monitoring plug-ins to add the given
|
||||
nodes to their monitoring domain. If the service node of the given nodes are
|
||||
not the localhost, the request will be sent to the conresponding service nodes.
|
||||
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 addNodes {
|
||||
my $p_input=shift;
|
||||
if ($p_input =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$p_input=shift;
|
||||
}
|
||||
|
||||
my %ret=();
|
||||
my @nodenames=@$p_input;
|
||||
if (@nodenames == 0) { return %ret; }
|
||||
|
||||
my $isSV=xCAT::Utils->isServiceNode();
|
||||
my @hostinfo=xCAT::Utils->determinehostname();
|
||||
%iphash=();
|
||||
foreach(@hostinfo) {$iphash{$_}=1;}
|
||||
|
||||
my $hierachy=xCAT_monitoring::monitorctrl->getMonServer(\@nodenames);
|
||||
my @mon_servers=keys(%$hierachy);
|
||||
|
||||
foreach (@mon_servers) {
|
||||
my $svname=$_;
|
||||
my $mon_nodes=$hierachy->{$svname};
|
||||
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");
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
} else {
|
||||
#forward them to the service nodes
|
||||
my @noderange=();
|
||||
foreach my $nodetemp (@$mon_nodes) {
|
||||
push(@noderange, $nodetemp->[0]);
|
||||
}
|
||||
my $cmd="psh $svname XCATBYPASS=Y monaddnode " . join(',', @noderange);
|
||||
my $result=`$cmd 2>&1`;
|
||||
if ($?) {
|
||||
$ret{$svname}=[1, $result];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return %ret;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 removeNodes
|
||||
This function informs all the active monitoring plug-ins to remove the given
|
||||
nodes to their monitoring domain. If the service node of the given nodes are
|
||||
not the localhost, the request will be sent to the conresponding service nodes.
|
||||
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 removeNodes {
|
||||
my $p_input=shift;
|
||||
if ($p_input =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$p_input=shift;
|
||||
}
|
||||
|
||||
my %ret=();
|
||||
my @nodenames=@$p_input;
|
||||
if (@nodenames == 0) { return %ret; }
|
||||
|
||||
my $isSV=xCAT::Utils->isServiceNode();
|
||||
my @hostinfo=xCAT::Utils->determinehostname();
|
||||
%iphash=();
|
||||
foreach(@hostinfo) {$iphash{$_}=1;}
|
||||
|
||||
my $hierachy=xCAT_monitoring::monitorctrl->getMonServer(\@nodenames);
|
||||
my @mon_servers=keys(%$hierachy);
|
||||
|
||||
foreach (@mon_servers) {
|
||||
my $svname=$_;
|
||||
my $mon_nodes=$hierachy->{$svname};
|
||||
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");
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
} else {
|
||||
#forward them to the service nodes
|
||||
my @noderange=();
|
||||
foreach my $nodetemp (@$mon_nodes) {
|
||||
push(@noderange, $nodetemp->[0]);
|
||||
}
|
||||
my $cmd="psh $svname XCATBYPASS=Y monrmnode " . join(',', @noderange);
|
||||
my $result=`$cmd 2>&1`;
|
||||
if ($?) {
|
||||
$ret{$svname}=[1, $result];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return %ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -155,32 +155,28 @@ sub stopNodeStatusMon {
|
||||
This function is called by the monitorctrl module when new nodes are added
|
||||
to the xCAT cluster. It should add the nodes into the product for monitoring.
|
||||
Arguments:
|
||||
nodes --nodes to be added. It is 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', 'bboting']...], ...}
|
||||
nodes --nodes to be added. It is a pointer to an array with each element
|
||||
being a ref to an array of [nodes, nodetype, status]. For example:
|
||||
[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']..]
|
||||
Returns:
|
||||
none
|
||||
(error code, error message)
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub addNodes {
|
||||
$noderef=shit;
|
||||
$noderef=shift;
|
||||
if ($noderef =~ /xCAT_monitoring::templatemon/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
|
||||
#demo how you can parse the input. you may commnet it out.
|
||||
foreach (keys(%$noderef)) {
|
||||
print " monitoring server: $_\n";
|
||||
my $mon_nodes=$noderef->{$_};
|
||||
foreach(@$mon_nodes) {
|
||||
my $node_info=$_;
|
||||
print " node=$node_info->[0], nodetype=$node_info->[1], status=$node_info->[2]\n";
|
||||
}
|
||||
|
||||
foreach(@$noderef) {
|
||||
my $node_info=$_;
|
||||
print " node=$node_info->[0], nodetype=$node_info->[1], status=$node_info->[2]\n";
|
||||
}
|
||||
|
||||
|
||||
#TODO: include the nodes into the product for monitoring.
|
||||
return;
|
||||
return (0, "0k");
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
@ -188,32 +184,28 @@ sub addNodes {
|
||||
This function is called by the monitorctrl module when nodes are removed
|
||||
from the xCAT cluster. It should remove the nodes from the product for monitoring.
|
||||
Arguments:
|
||||
nodes --nodes to be removed. It is 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']...], ...}
|
||||
nodes --nodes to be removed. It is a pointer to an array with each element
|
||||
being a ref to an array of [nodes, nodetype, status]. For example:
|
||||
[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']..]
|
||||
Returns:
|
||||
none
|
||||
(error code, error message)
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub removeNodes {
|
||||
$noderef=shit;
|
||||
$noderef=shift;
|
||||
if ($noderef =~ /xCAT_monitoring::templatemon/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
|
||||
#demo how you can parse the input. you may commnet it out.
|
||||
foreach (keys(%$noderef)) {
|
||||
print " monitoring server: $_\n";
|
||||
my $mon_nodes=$noderef->{$_};
|
||||
foreach(@$mon_nodes) {
|
||||
my $node_info=$_;
|
||||
print " node=$node_info->[0], nodetype=$node_info->[1], status=$node_info->[2]\n";
|
||||
}
|
||||
foreach(@$noderef) {
|
||||
my $node_info=$_;
|
||||
print " node=$node_info->[0], nodetype=$node_info->[1], status=$node_info->[2]\n";
|
||||
}
|
||||
|
||||
|
||||
#TODO: remove the nodes from the product for monitoring.
|
||||
return;
|
||||
return (0, "ok");
|
||||
}
|
||||
|
||||
|
||||
|
@ -346,36 +346,52 @@ sub stopNodeStatusMon {
|
||||
=head3 addNodes
|
||||
This function adds the nodes into the SNMP domain.
|
||||
Arguments:
|
||||
nodes --nodes to be added. It is 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']...], ...}
|
||||
verbose -- verbose mode. 1 for yes, 0 for no.
|
||||
nodes --nodes to be added. It is a pointer to an array with each element
|
||||
being a ref to an array of [nodes, nodetype, status]. For example:
|
||||
[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']..]
|
||||
Returns:
|
||||
none
|
||||
(error code, error message)
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub addNodes {
|
||||
print "snmpmon::addNodes\n";
|
||||
$noderef=shift;
|
||||
if ($noderef =~ /xCAT_monitoring::snmpmon/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
|
||||
foreach(@$noderef) {
|
||||
my $node_info=$_;
|
||||
print " node=$node_info->[0], nodetype=$node_info->[1], status=$node_info->[2]\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (0, "ok");
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 removeNodes
|
||||
This function removes the nodes from the SNMP domain.
|
||||
Arguments:
|
||||
nodes --nodes to be removed. It is 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']...], ...}
|
||||
verbose -- verbose mode. 1 for yes, 0 for no.
|
||||
nodes --nodes to be removed. It is a pointer to an array with each element
|
||||
being a ref to an array of [nodes, nodetype, status]. For example:
|
||||
[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']..]
|
||||
Returns:
|
||||
none
|
||||
(error code, error message)
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub removeNodes {
|
||||
print "snmpmon::removeNodes\n";
|
||||
$noderef=shift;
|
||||
if ($noderef =~ /xCAT_monitoring::snmpmon/) {
|
||||
$noderef=shift;
|
||||
}
|
||||
|
||||
return 0;
|
||||
foreach(@$noderef) {
|
||||
my $node_info=$_;
|
||||
print " node=$node_info->[0], nodetype=$node_info->[1], status=$node_info->[2]\n";
|
||||
}
|
||||
|
||||
return (0, "ok");
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
|
@ -166,19 +166,18 @@ sub stopNodeStatusMon {
|
||||
This function is called by the monitorctrl module when new nodes are added
|
||||
to the xCAT cluster. It should add the nodes into the product for monitoring.
|
||||
Arguments:
|
||||
nodes --nodes to be added. It is 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']...], ...}
|
||||
nodes --nodes to be added. It is a pointer to an array with each element
|
||||
being a ref to an array of [nodes, nodetype, status]. For example:
|
||||
[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']..]
|
||||
Returns:
|
||||
none
|
||||
(error code, error message)
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub addNodes {
|
||||
|
||||
#print "xcatmon:addNodes called\n";
|
||||
|
||||
return;
|
||||
return (0, "ok");
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
@ -186,19 +185,18 @@ sub addNodes {
|
||||
This function is called by the monitorctrl module when nodes are removed
|
||||
from the xCAT cluster. It should remove the nodes from the product for monitoring.
|
||||
Arguments:
|
||||
nodes --nodes to be removed. It is a hash reference keyed by the monitoring server
|
||||
nodes and each value is a ref to an array of [nodes, nodetype] arrays monitored
|
||||
by the server. So the format is:
|
||||
{monserver1=>[['node1', 'osi'], ['node2', 'switch']...], ...}
|
||||
nodes --nodes to be removed. It is a pointer to an array with each element
|
||||
being a ref to an array of [nodes, nodetype, status]. For example:
|
||||
[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']..]
|
||||
Returns:
|
||||
none
|
||||
(error code, error message)
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub removeNodes {
|
||||
|
||||
#print "xcatmon:removeNodes called\n";
|
||||
|
||||
return;
|
||||
return (0, "ok");
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,10 +36,12 @@ use xCAT::Utils;
|
||||
#--------------------------------------------------------------------------------
|
||||
sub handled_commands {
|
||||
return {
|
||||
startmon => "monctrlcmds",
|
||||
stopmon => "monctrlcmds",
|
||||
updatemon => "monctrlcmds",
|
||||
lsmon => "monctrlcmds",
|
||||
monstart => "monctrlcmds",
|
||||
monstop => "monctrlcmds",
|
||||
monupdate => "monctrlcmds",
|
||||
monls => "monctrlcmds",
|
||||
monaddnode => "monctrlcmds",
|
||||
monrmnode => "monctrlcmds",
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,8 +68,8 @@ sub process_request {
|
||||
my $command = $request->{command}->[0];
|
||||
my $args=$request->{arg};
|
||||
|
||||
if ($command eq "startmon") {
|
||||
my ($ret, $msg) = startmon($args, $callback);
|
||||
if ($command eq "monstart") {
|
||||
my ($ret, $msg) = monstart($args, $callback);
|
||||
if ($msg) {
|
||||
my %rsp=();
|
||||
$rsp->{dara}->[0]= $msg;
|
||||
@ -75,8 +77,8 @@ sub process_request {
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
elsif ($command eq "stopmon") {
|
||||
my ($ret, $msg) = stopmon($args, $callback);
|
||||
elsif ($command eq "monstop") {
|
||||
my ($ret, $msg) = monstop($args, $callback);
|
||||
if ($msg) {
|
||||
my %rsp=();
|
||||
$rsp->{data}->[0]= $msg;
|
||||
@ -84,11 +86,29 @@ sub process_request {
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
elsif ($command eq "updatemon") {
|
||||
elsif ($command eq "monupdate") {
|
||||
xCAT_monitoring::monitorctrl::sendMonSignal();
|
||||
}
|
||||
elsif ($command eq "lsmon") {
|
||||
my ($ret, $msg) = lsmon($args, $callback);
|
||||
elsif ($command eq "monls") {
|
||||
my ($ret, $msg) = monls($args, $callback);
|
||||
if ($msg) {
|
||||
my %rsp=();
|
||||
$rsp->{data}->[0]= $msg;
|
||||
$callback->($rsp);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
elsif ($command eq "monaddnode") {
|
||||
my ($ret, $msg) = monaddnode($args, $callback);
|
||||
if ($msg) {
|
||||
my %rsp=();
|
||||
$rsp->{data}->[0]= $msg;
|
||||
$callback->($rsp);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
elsif ($command eq "monrmnode") {
|
||||
my ($ret, $msg) = monrmnode($args, $callback);
|
||||
if ($msg) {
|
||||
my %rsp=();
|
||||
$rsp->{data}->[0]= $msg;
|
||||
@ -106,7 +126,7 @@ sub process_request {
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 startmon
|
||||
=head3 monstart
|
||||
This function registers the given monitoring plug-in to the 'monitoring' table.
|
||||
xCAT will invoke the monitoring plug-in to start the 3rd party software, which
|
||||
this plug-in connects to, to monitor the xCAT cluster.
|
||||
@ -128,7 +148,7 @@ sub process_request {
|
||||
1. for unsuccess. The error messages are returns through the callback pointer.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub startmon {
|
||||
sub monstart {
|
||||
my $args=shift;
|
||||
my $callback=shift;
|
||||
my $VERSION;
|
||||
@ -143,19 +163,19 @@ sub startmon {
|
||||
|
||||
|
||||
# subroutine to display the usage
|
||||
sub startmon_usage
|
||||
sub monstart_usage
|
||||
{
|
||||
my %rsp;
|
||||
$rsp->{data}->[0]= "Usage:";
|
||||
$rsp->{data}->[1]= " startmon name [-n|--nodestatmon] [-s|--settings settings]";
|
||||
$rsp->{data}->[2]= " startmon [-h|--help|-v|--version]";
|
||||
$rsp->{data}->[1]= " monstart name [-n|--nodestatmon] [-s|--settings settings]";
|
||||
$rsp->{data}->[2]= " monstart [-h|--help|-v|--version]";
|
||||
$rsp->{data}->[3]= " name is the name of the monitoring plug-in module to be registered and invoked.";
|
||||
$rsp->{data}->[4]= " Use 'lsmon -a' command to list all the monitoring plug-in names.";
|
||||
$rsp->{data}->[4]= " Use 'monls -a' command to list all the monitoring plug-in names.";
|
||||
$rsp->{data}->[5]= " settings is used by the monitoring plug-in to customize its behavior.";
|
||||
$rsp->{data}->[6]= " Format: [key1=value1],[key2=value2]... ";
|
||||
$rsp->{data}->[7]= " Please note that the square brackets are needed. ";
|
||||
$rsp->{data}->[7]= " Use 'lsmon name -d' command to look for the possible settings for a plug-in.";
|
||||
$rsp->{data}->[8]= " Example: startmon xcatmon -n -s [ping-interval=10]";
|
||||
$rsp->{data}->[7]= " Use 'monls name -d' command to look for the possible settings for a plug-in.";
|
||||
$rsp->{data}->[8]= " Example: monstart xcatmon -n -s [ping-interval=10]";
|
||||
$callback->($rsp);
|
||||
}
|
||||
|
||||
@ -169,13 +189,13 @@ sub startmon {
|
||||
'n|nodestatmon' => \$::NODESTATMON,
|
||||
's|settings=s' => \$settings))
|
||||
{
|
||||
&startmon_usage;
|
||||
&monstart_usage;
|
||||
return;
|
||||
}
|
||||
|
||||
# display the usage if -h or --help is specified
|
||||
if ($::HELP) {
|
||||
&startmon_usage;
|
||||
&monstart_usage;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -183,7 +203,7 @@ sub startmon {
|
||||
if ($::VERSION)
|
||||
{
|
||||
my %rsp;
|
||||
$rsp->{data}->[0]= "startmon version 1.0";
|
||||
$rsp->{data}->[0]= "monstart version 1.0";
|
||||
$callback->($rsp);
|
||||
return;
|
||||
}
|
||||
@ -192,7 +212,7 @@ sub startmon {
|
||||
my $pname;
|
||||
if (@ARGV < 1)
|
||||
{
|
||||
&startmon_usage;
|
||||
&monstart_usage;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@ -216,7 +236,7 @@ sub startmon {
|
||||
}
|
||||
}
|
||||
|
||||
#my %ret = xCAT_monitoring::monitorctrl::startMonitoring(@product_names);
|
||||
#my %ret = xCAT_monitoring::monitorctrl::startmonitoring(@product_names);
|
||||
|
||||
#my %rsp;
|
||||
#$rsp->{data}->[0]= "starting @product_names";
|
||||
@ -282,7 +302,7 @@ sub startmon {
|
||||
my %rsp2;
|
||||
$rsp2->{data}->[0]="sending request to $_...";
|
||||
$callback->($rsp2);
|
||||
my $result=`psh --nonodecheck $_ updatemon 2>1&`;
|
||||
my $result=`psh --nonodecheck $_ monupdate 2>1&`;
|
||||
if ($result) {
|
||||
$rsp2->{data}->[0]="$result";
|
||||
$callback->($rsp2);
|
||||
@ -298,7 +318,7 @@ sub startmon {
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 stopmon
|
||||
=head3 monstop
|
||||
This function unregisters the given monitoring plug-in from the 'monitoring' table.
|
||||
xCAT will ask the monitoring plug-in to stop the 3rd party software, which
|
||||
this plug-in connects to, to monitor the xCAT cluster.
|
||||
@ -316,7 +336,7 @@ sub startmon {
|
||||
1. for unsuccess. The error messages are returns through the callback pointer.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub stopmon {
|
||||
sub monstop {
|
||||
my $args=shift;
|
||||
my $callback=shift;
|
||||
my $VERSION;
|
||||
@ -330,12 +350,12 @@ sub stopmon {
|
||||
}
|
||||
|
||||
# subroutine to display the usage
|
||||
sub stopmon_usage
|
||||
sub monstop_usage
|
||||
{
|
||||
my %rsp;
|
||||
$rsp->{data}->[0]= "Usage:";
|
||||
$rsp->{data}->[1]= " stopmon name";
|
||||
$rsp->{data}->[2]= " stopmon [-h|--help|-v|--version]";
|
||||
$rsp->{data}->[1]= " monstop name";
|
||||
$rsp->{data}->[2]= " monstop [-h|--help|-v|--version]";
|
||||
$rsp->{data}->[3]= " name is the name of the monitoring plug-in module registered in the monitoring table.";
|
||||
$callback->($rsp);
|
||||
}
|
||||
@ -346,13 +366,13 @@ sub stopmon {
|
||||
'h|help' => \$::HELP,
|
||||
'v|version' => \$::VERSION,))
|
||||
{
|
||||
&stopmon_usage;
|
||||
&monstop_usage;
|
||||
return;
|
||||
}
|
||||
|
||||
# display the usage if -h or --help is specified
|
||||
if ($::HELP) {
|
||||
&stopmon_usage;
|
||||
&monstop_usage;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -360,7 +380,7 @@ sub stopmon {
|
||||
if ($::VERSION)
|
||||
{
|
||||
my %rsp;
|
||||
$rsp->{data}->[0]= "stopmon version 1.0";
|
||||
$rsp->{data}->[0]= "monstop version 1.0";
|
||||
$callback->($rsp);
|
||||
return;
|
||||
}
|
||||
@ -370,7 +390,7 @@ sub stopmon {
|
||||
my $pname;
|
||||
if (@ARGV < 1)
|
||||
{
|
||||
&stopmon_usage;
|
||||
&monstop_usage;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@ -423,7 +443,7 @@ sub stopmon {
|
||||
my %rsp2;
|
||||
$rsp2->{data}->[0]="sending request to $_...";
|
||||
$callback->($rsp2);
|
||||
my $result=`psh --nonodecheck $_ updatemon 2>1&`;
|
||||
my $result=`psh --nonodecheck $_ monupdate 2>1&`;
|
||||
if ($result) {
|
||||
$rsp2->{data}->[0]="$result";
|
||||
$callback->($rsp2);
|
||||
@ -440,7 +460,7 @@ sub stopmon {
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 lsmon
|
||||
=head3 monls
|
||||
This function list the monitoring plug-in module names, status and description.
|
||||
Arguments:
|
||||
callback - the pointer to the callback function.
|
||||
@ -452,20 +472,20 @@ sub stopmon {
|
||||
1. for unsuccess. The error messages are returns through the callback pointer.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub lsmon {
|
||||
sub monls {
|
||||
my $args=shift;
|
||||
my $callback=shift;
|
||||
my $VERSION;
|
||||
my $HELP;
|
||||
|
||||
# subroutine to display the usage
|
||||
sub lsmon_usage
|
||||
sub monls_usage
|
||||
{
|
||||
my %rsp;
|
||||
$rsp->{data}->[0]= "Usage:";
|
||||
$rsp->{data}->[1]= " lsmon name [-d|--description]";
|
||||
$rsp->{data}->[2]= " lsmon [-a|--all] [-d|--description]";
|
||||
$rsp->{data}->[3]= " lsmon [-h|--help|-v|--version]";
|
||||
$rsp->{data}->[1]= " monls name [-d|--description]";
|
||||
$rsp->{data}->[2]= " monls [-a|--all] [-d|--description]";
|
||||
$rsp->{data}->[3]= " monls [-h|--help|-v|--version]";
|
||||
$rsp->{data}->[4]= " name is the name of the monitoring plug-in module.";
|
||||
$callback->($rsp);
|
||||
}
|
||||
@ -479,13 +499,13 @@ sub lsmon {
|
||||
'a|all' => \$::ALL,
|
||||
'd|discription' => \$::DESC))
|
||||
{
|
||||
&lsmon_usage;
|
||||
&monls_usage;
|
||||
return;
|
||||
}
|
||||
|
||||
# display the usage if -h or --help is specified
|
||||
if ($::HELP) {
|
||||
&lsmon_usage;
|
||||
&monls_usage;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -493,7 +513,7 @@ sub lsmon {
|
||||
if ($::VERSION)
|
||||
{
|
||||
my %rsp;
|
||||
$rsp->{data}->[0]= "lsmon version 1.0";
|
||||
$rsp->{data}->[0]= "monls version 1.0";
|
||||
$callback->($rsp);
|
||||
return;
|
||||
}
|
||||
@ -586,8 +606,184 @@ sub lsmon {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 monaddnode
|
||||
This function informs all the active monitoring plug-ins to add the given
|
||||
nodes to their monitoring domain
|
||||
Arguments:
|
||||
callback - the pointer to the callback function.
|
||||
args - The format of the args is:
|
||||
[-h|--help|-v|--version] or
|
||||
noderange
|
||||
Returns:
|
||||
0 for success. The output is returned through the callback pointer.
|
||||
1. for unsuccess. The error messages are returns through the callback pointer.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub monaddnode {
|
||||
my $args=shift;
|
||||
my $callback=shift;
|
||||
my $VERSION;
|
||||
my $HELP;
|
||||
|
||||
# subroutine to display the usage
|
||||
sub monaddnode_usage
|
||||
{
|
||||
my %rsp;
|
||||
$rsp->{data}->[0]= "Usage:";
|
||||
$rsp->{data}->[1]= " monaddnode noderange";
|
||||
$rsp->{data}->[2]= " monaddnode [-h|--help|-v|--version]";
|
||||
$rsp->{data}->[3]= " noderange is a list of comma separated node or node group names.";
|
||||
$callback->($rsp);
|
||||
}
|
||||
|
||||
@ARGV=@{$args};
|
||||
# parse the options
|
||||
if(!GetOptions(
|
||||
'h|help' => \$::HELP,
|
||||
'v|version' => \$::VERSION,))
|
||||
{
|
||||
&monaddnode_usage;
|
||||
return;
|
||||
}
|
||||
|
||||
# display the usage if -h or --help is specified
|
||||
if ($::HELP) {
|
||||
&monaddnode_usage;
|
||||
return;
|
||||
}
|
||||
|
||||
# display the version statement if -v or --verison is specified
|
||||
if ($::VERSION)
|
||||
{
|
||||
my %rsp;
|
||||
$rsp->{data}->[0]= "monaddnode version 1.0";
|
||||
$callback->($rsp);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
my $noderange;
|
||||
if (@ARGV < 1)
|
||||
{
|
||||
&monaddnode_usage;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$noderange=$ARGV[0];
|
||||
}
|
||||
|
||||
my @nodenames=noderange($noderange);
|
||||
my @missed=nodesmissed();
|
||||
if (@missed > 0) {
|
||||
my %rsp1;
|
||||
$rsp1->{data}->[0]="Invalide nodes:@missed";
|
||||
$callback->($rsp1);
|
||||
return;
|
||||
}
|
||||
|
||||
my %ret=xCAT_monitoring::monitorctrl->addNodes(\@nodenames);
|
||||
|
||||
if (%ret) {
|
||||
foreach(keys(%ret)) {
|
||||
my $retstat=$ret{$_};
|
||||
my %rsp1;
|
||||
$rsp1->{data}->[0]="$_: @$retstat";
|
||||
$callback->($rsp1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 monrmnode
|
||||
This function informs all the active monitoring plug-ins to remove the given
|
||||
nodes to their monitoring domain
|
||||
Arguments:
|
||||
callback - the pointer to the callback function.
|
||||
args - The format of the args is:
|
||||
[-h|--help|-v|--version] or
|
||||
noderange
|
||||
Returns:
|
||||
0 for success. The output is returned through the callback pointer.
|
||||
1. for unsuccess. The error messages are returns through the callback pointer.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub monrmnode {
|
||||
my $args=shift;
|
||||
my $callback=shift;
|
||||
my $VERSION;
|
||||
my $HELP;
|
||||
|
||||
# subroutine to display the usage
|
||||
sub monrmnode_usage
|
||||
{
|
||||
my %rsp;
|
||||
$rsp->{data}->[0]= "Usage:";
|
||||
$rsp->{data}->[1]= " monrmnode noderange";
|
||||
$rsp->{data}->[2]= " monrmnode [-h|--help|-v|--version]";
|
||||
$rsp->{data}->[3]= " noderange is a list of comma separated node or node group names.";
|
||||
$callback->($rsp);
|
||||
}
|
||||
|
||||
@ARGV=@{$args};
|
||||
# parse the options
|
||||
if(!GetOptions(
|
||||
'h|help' => \$::HELP,
|
||||
'v|version' => \$::VERSION,))
|
||||
{
|
||||
&monrmnode_usage;
|
||||
return;
|
||||
}
|
||||
|
||||
# display the usage if -h or --help is specified
|
||||
if ($::HELP) {
|
||||
&monrmnode_usage;
|
||||
return;
|
||||
}
|
||||
|
||||
# display the version statement if -v or --verison is specified
|
||||
if ($::VERSION)
|
||||
{
|
||||
my %rsp;
|
||||
$rsp->{data}->[0]= "monrmnode version 1.0";
|
||||
$callback->($rsp);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
my $noderange;
|
||||
if (@ARGV < 1)
|
||||
{
|
||||
&monrmnode_usage;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$noderange=$ARGV[0];
|
||||
}
|
||||
|
||||
my @nodenames=noderange($noderange, 0);
|
||||
if (@nodenames==0) { return 0;}
|
||||
|
||||
my %ret=xCAT_monitoring::monitorctrl->removeNodes(\@nodenames);
|
||||
if (%ret) {
|
||||
foreach(keys(%ret)) {
|
||||
my $retstat=$ret{$_};
|
||||
my %rsp1;
|
||||
$rsp1->{data}->[0]="$_: @$retstat";
|
||||
$callback->($rsp1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user