2008-08-14 20:22:59 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
package xCAT_monitoring::gangliamon;
|
|
|
|
BEGIN
|
|
|
|
{
|
|
|
|
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
|
|
|
|
}
|
|
|
|
use lib "$::XCATROOT/lib/perl";
|
|
|
|
use xCAT::NodeRange;
|
|
|
|
use Sys::Hostname;
|
|
|
|
use Socket;
|
|
|
|
use xCAT::Utils;
|
|
|
|
use xCAT::GlobalDef;
|
|
|
|
use xCAT_monitoring::monitorctrl;
|
|
|
|
use xCAT::MsgUtils;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
1;
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
=head1 xCAT_monitoring:gangliamon
|
|
|
|
=head2 Package Description
|
2008-08-19 18:58:23 +00:00
|
|
|
xCAT monitoring plugin package to handle Ganglia monitoring.
|
2008-08-14 20:22:59 +00:00
|
|
|
=cut
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
=head3 start
|
|
|
|
This function gets called by the monitorctrl module when xcatd starts and
|
|
|
|
when monstart command is issued by the user. It starts the daemons and
|
|
|
|
does necessary startup process for the Ganglia monitoring.
|
|
|
|
p_nodes -- a pointer to an arrays of nodes to be monitored. null means all.
|
|
|
|
scope -- the action scope, it indicates the node type the action will take place.
|
|
|
|
0 means localhost only.
|
|
|
|
2 means both localhost and nodes,
|
|
|
|
callback -- the callback pointer for error and status displaying. It can be null.
|
|
|
|
Returns:
|
|
|
|
(return code, message)
|
|
|
|
if the callback is set, use callback to display the status and error.
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
sub start
|
|
|
|
{ # starting sub routine
|
|
|
|
print "gangliamon::start called\n";
|
|
|
|
my $noderef=shift;
|
|
|
|
if ($noderef =~ /xCAT_monitoring::gangliamon/)
|
|
|
|
{
|
|
|
|
$noderef=shift;
|
|
|
|
}
|
|
|
|
my $scope=shift;
|
|
|
|
my $callback=shift;
|
|
|
|
my $localhost=hostname();
|
2008-11-11 15:28:54 +00:00
|
|
|
my $OS=`uname`;
|
|
|
|
my $res_gmond;
|
|
|
|
if ( $OS =~ /AIX/ )
|
|
|
|
{
|
|
|
|
$res_gmond = `/etc/rc.d/init.d/gmond restart 2>&1`;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$res_gmond = `/etc/init.d/gmond restart 2>&1`;
|
|
|
|
}
|
2008-08-14 20:22:59 +00:00
|
|
|
if ($?)
|
|
|
|
{
|
|
|
|
if ($callback)
|
|
|
|
{
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: Ganglia Gmond not started successfully: $res_gmond \n";
|
|
|
|
$callback->($resp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: $res_gmond \n");
|
|
|
|
}
|
|
|
|
|
2008-08-19 18:58:23 +00:00
|
|
|
return(1,"Ganglia Gmond not started successfully. \n");
|
2008-08-14 20:22:59 +00:00
|
|
|
}
|
|
|
|
|
2008-11-11 15:28:54 +00:00
|
|
|
my $res_gmetad;
|
|
|
|
if ( $OS =~ /AIX/ )
|
|
|
|
{
|
|
|
|
$res_gmetad = `/etc/rc.d/init.d/gmetad restart 2>&1`;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$res_gmetad = `/etc/init.d/gmetad restart 2>&1`;
|
|
|
|
}
|
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
if ($?)
|
|
|
|
{
|
|
|
|
if ($callback)
|
|
|
|
{
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: Ganglia Gmetad not started successfully:$res_gmetad \n";
|
|
|
|
$callback->($resp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: $res_gmetad \n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return(1,"Ganglia Gmetad not started successfully. \n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($scope)
|
|
|
|
{ #opening if scope
|
2008-11-11 15:28:54 +00:00
|
|
|
my $OS=`uname`;
|
2008-08-14 20:22:59 +00:00
|
|
|
my $pPairHash=xCAT_monitoring::monitorctrl->getMonServer($noderef);
|
2009-03-17 21:07:21 +00:00
|
|
|
if (ref($pPairHash) eq 'ARRAY') {
|
|
|
|
if ($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]=$pPairHash->[1];
|
|
|
|
$callback->($resp);
|
|
|
|
} else {
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: " . $pPairHash->[1]);
|
|
|
|
}
|
|
|
|
return (1, "");
|
|
|
|
}
|
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
#identification of this node
|
|
|
|
my @hostinfo=xCAT::Utils->determinehostname();
|
|
|
|
my $isSV=xCAT::Utils->isServiceNode();
|
|
|
|
my %iphash=();
|
|
|
|
foreach(@hostinfo) {$iphash{$_}=1;}
|
|
|
|
if (!$isSV) { $iphash{'noservicenode'}=1;}
|
|
|
|
|
|
|
|
my @children;
|
|
|
|
foreach my $key (keys (%$pPairHash))
|
|
|
|
{ #opening foreach1
|
2009-03-17 21:07:21 +00:00
|
|
|
my @key_a=split(':', $key);
|
|
|
|
if (! $iphash{$key_a[0]}) { next; }
|
2008-08-14 20:22:59 +00:00
|
|
|
my $mon_nodes=$pPairHash->{$key};
|
|
|
|
|
2009-03-17 21:07:21 +00:00
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
foreach(@$mon_nodes)
|
|
|
|
{ #opening foreach2
|
|
|
|
my $node=$_->[0];
|
|
|
|
my $nodetype=$_->[1];
|
|
|
|
if (($nodetype) && ($nodetype =~ /$::NODETYPE_OSI/))
|
|
|
|
{
|
|
|
|
push(@children,$node);
|
|
|
|
}
|
|
|
|
} #closing foreach2
|
|
|
|
} #closing foreach1
|
2009-03-31 09:44:14 +00:00
|
|
|
my $rec = undef;
|
|
|
|
my $result = undef;
|
|
|
|
if(exists($children[0])){
|
|
|
|
$rec = join(',',@children);
|
|
|
|
}
|
|
|
|
if($rec){
|
|
|
|
if ( $OS =~ /AIX/ )
|
|
|
|
{
|
|
|
|
$result = `XCATBYPASS=Y $::XCATROOT/bin/xdsh $rec /etc/rc.d/init.d/gmond restart 2>&1`;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = `XCATBYPASS=Y $::XCATROOT/bin/xdsh $rec /etc/init.d/gmond restart 2>&1`;
|
|
|
|
}
|
2008-11-11 15:28:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($result)
|
2008-08-14 20:22:59 +00:00
|
|
|
{
|
|
|
|
if ($callback)
|
|
|
|
{
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: $result\n";
|
|
|
|
$callback->($resp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: $result\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} #closing if scope
|
|
|
|
|
|
|
|
if ($callback)
|
|
|
|
{
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: started. \n";
|
|
|
|
$callback->($resp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0, "started");
|
|
|
|
|
|
|
|
} # closing sub routine
|
|
|
|
#--------------------------------------------------------------
|
|
|
|
=head3 config
|
|
|
|
This function configures the cluster for the given nodes. This function is called
|
|
|
|
when moncfg command is issued or when xcatd starts on the service node. It will
|
2008-08-18 17:45:51 +00:00
|
|
|
configure the cluster to include the given nodes within the monitoring domain. This
|
|
|
|
calls two other functions called as confGmond and confGmetad which are used for configuring
|
2008-08-14 20:22:59 +00:00
|
|
|
the Gmond and Gmetad configuration files respectively.
|
|
|
|
Arguments:
|
|
|
|
p_nodes -- a pointer to an arrays of nodes to be added for monitoring. none means all.
|
|
|
|
scope -- the action scope, it indicates the node type the action will take place.
|
|
|
|
0 means localhost only.
|
|
|
|
2 means localhost and nodes,
|
|
|
|
callback -- the callback pointer for error and status displaying. It can be null.
|
|
|
|
Returns:
|
|
|
|
(error code, error message)
|
|
|
|
=cut
|
|
|
|
#--------------------------------------------------------------
|
|
|
|
sub config
|
|
|
|
{
|
|
|
|
print "gangliamon:config called\n";
|
|
|
|
my $noderef=shift;
|
|
|
|
if ($noderef =~ /xCAT_monitoring::gangliamon/) {
|
|
|
|
$noderef=shift;
|
|
|
|
}
|
|
|
|
my $scope=shift;
|
|
|
|
my $callback=shift;
|
|
|
|
|
|
|
|
confGmond($noderef,$scope,$callback);
|
|
|
|
confGmetad($noderef,$scope,$callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------
|
|
|
|
=head3 confGmond
|
|
|
|
This function is called by the config() function. It configures the Gmond
|
|
|
|
configuration files for the given nodes
|
|
|
|
Arguments:
|
|
|
|
p_nodes -- a pointer to an arrays of nodes to be added for monitoring. none means all.
|
|
|
|
scope -- the action scope, it indicates the node type the action will take place.
|
|
|
|
0 means localhost only.
|
|
|
|
2 means localhost and nodes,
|
|
|
|
callback -- the callback pointer for error and status displaying. It can be null.
|
2008-08-20 18:17:21 +00:00
|
|
|
Returns: none
|
2008-08-14 20:22:59 +00:00
|
|
|
=cut
|
|
|
|
#--------------------------------------------------------------
|
|
|
|
|
|
|
|
sub confGmond
|
2009-03-17 21:07:21 +00:00
|
|
|
{
|
2008-08-14 20:22:59 +00:00
|
|
|
print "gangliamon:confGmond called \n";
|
2009-03-17 21:07:21 +00:00
|
|
|
no warnings;
|
|
|
|
# no strict 'vars';
|
2008-08-14 20:22:59 +00:00
|
|
|
my $noderef=shift;
|
|
|
|
if ($noderef =~ /xCAT_monitoring::gangliamon/) {
|
2009-03-17 21:07:21 +00:00
|
|
|
$noderef=shift;
|
2008-08-14 20:22:59 +00:00
|
|
|
}
|
|
|
|
my $scope=shift;
|
|
|
|
my $callback=shift;
|
2009-03-17 21:07:21 +00:00
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
my $localhost=hostname();
|
2009-03-17 21:07:21 +00:00
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
chomp(my $hostname = `hostname`);
|
2009-03-17 21:07:21 +00:00
|
|
|
if (-e "/etc/ganglia/gmond.conf")
|
|
|
|
{ #opening if 3.1.0
|
2008-09-03 19:00:10 +00:00
|
|
|
`/bin/grep "xCAT gmond settings done" /etc/ganglia/gmond.conf`;
|
2009-03-17 21:07:21 +00:00
|
|
|
|
|
|
|
if($?)
|
2008-08-14 20:22:59 +00:00
|
|
|
{ #openinf if ?
|
2009-03-17 21:07:21 +00:00
|
|
|
if($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: $?";
|
|
|
|
$callback->($resp);
|
|
|
|
} else { xCAT::MsgUtils->message('S', "Gmond not configured $? \n"); }
|
|
|
|
|
2008-09-03 19:00:10 +00:00
|
|
|
#backup the original file
|
|
|
|
`/bin/cp -f /etc/ganglia/gmond.conf /etc/ganglia/gmond.conf.orig`;
|
2009-03-17 21:07:21 +00:00
|
|
|
my $master=xCAT::Utils->get_site_Master();
|
|
|
|
open(FILE1, "</etc/ganglia/gmond.conf");
|
|
|
|
open(FILE, "+>/etc/ganglia/gmond.conf.tmp");
|
|
|
|
my $fname = "/etc/ganglia/gmond.conf";
|
|
|
|
unless ( open( CONF, $fname ))
|
|
|
|
{
|
2008-09-03 19:00:10 +00:00
|
|
|
return(0);
|
2009-03-17 21:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
my @raw_data = <CONF>;
|
|
|
|
close( CONF );
|
|
|
|
my $str = join('',@raw_data);
|
|
|
|
$str =~ s/setuid = yes/setuid = no/;
|
|
|
|
$str =~ s/bind/#bind/;
|
|
|
|
$str =~ s/mcast_join = .*/host = $master/;
|
2008-09-03 19:00:10 +00:00
|
|
|
|
|
|
|
my $pPairHash=xCAT_monitoring::monitorctrl->getMonServer($noderef);
|
2009-03-17 21:07:21 +00:00
|
|
|
if (ref($pPairHash) eq 'ARRAY') {
|
|
|
|
if ($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]=$pPairHash->[1];
|
|
|
|
$callback->($resp);
|
|
|
|
} else {
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: " . $pPairHash->[1]);
|
|
|
|
}
|
|
|
|
return (1, "");
|
|
|
|
}
|
|
|
|
|
2008-09-03 19:00:10 +00:00
|
|
|
#identification of this node
|
|
|
|
my @hostinfo=xCAT::Utils->determinehostname();
|
|
|
|
my $isSV=xCAT::Utils->isServiceNode();
|
|
|
|
my %iphash=();
|
|
|
|
foreach(@hostinfo) {$iphash{$_}=1;}
|
|
|
|
if (!$isSV) { $iphash{'noservicenode'}=1;}
|
2009-03-17 21:07:21 +00:00
|
|
|
|
|
|
|
# my @children;
|
2008-09-03 19:00:10 +00:00
|
|
|
foreach my $key (keys (%$pPairHash))
|
2009-03-17 21:07:21 +00:00
|
|
|
{ #opening for each
|
|
|
|
my @key_a=split(':', $key);
|
|
|
|
if (! $iphash{$key_a[0]}) { next; }
|
|
|
|
my $pattern = '^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})';
|
|
|
|
if ( $key_a[0]!~/$pattern/ )
|
2008-09-03 19:00:10 +00:00
|
|
|
{
|
2009-03-17 21:07:21 +00:00
|
|
|
my $cluster = $key_a[0];
|
|
|
|
if (-e "/etc/xCATSN")
|
|
|
|
{
|
|
|
|
$str =~ s/name = "unspecified"/name="$cluster"/;
|
|
|
|
}
|
2008-09-03 19:00:10 +00:00
|
|
|
}
|
2009-03-17 21:07:21 +00:00
|
|
|
|
|
|
|
} #closing for each
|
|
|
|
|
|
|
|
$str =~ s/name = "unspecified"/name="$hostname"/;
|
|
|
|
$str =~ s/mcast_join/# mcast_join/;
|
|
|
|
print FILE $str;
|
|
|
|
print FILE "# xCAT gmond settings done \n";
|
|
|
|
close(FILE1);
|
|
|
|
close(FILE);
|
2008-09-03 19:00:10 +00:00
|
|
|
`/bin/cp -f /etc/ganglia/gmond.conf.tmp /etc/ganglia/gmond.conf`;
|
2009-03-17 21:07:21 +00:00
|
|
|
|
|
|
|
# } #closing for each
|
|
|
|
|
|
|
|
} #closing if ?
|
|
|
|
|
|
|
|
} #closing if 3.1.0
|
|
|
|
|
|
|
|
else
|
|
|
|
{ #opening if 3.0.7
|
|
|
|
`/bin/grep "xCAT gmond settings done" /etc/gmond.conf`;
|
|
|
|
|
|
|
|
if($?)
|
|
|
|
{ #openinf if ?
|
|
|
|
if($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: $?";
|
|
|
|
$callback->($resp);
|
|
|
|
} else { xCAT::MsgUtils->message('S', "Gmond not configured $? \n"); }
|
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
#backup the original file
|
|
|
|
`/bin/cp -f /etc/gmond.conf /etc/gmond.conf.orig`;
|
2009-03-17 21:07:21 +00:00
|
|
|
my $master=xCAT::Utils->get_site_Master();
|
|
|
|
open(FILE1, "</etc/gmond.conf");
|
|
|
|
open(FILE, "+>/etc/gmond.conf.tmp");
|
|
|
|
my $fname = "/etc/gmond.conf";
|
|
|
|
unless ( open( CONF, $fname ))
|
|
|
|
{
|
2008-08-14 20:22:59 +00:00
|
|
|
return(0);
|
2009-03-17 21:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
my @raw_data = <CONF>;
|
|
|
|
close( CONF );
|
|
|
|
my $str = join('',@raw_data);
|
|
|
|
$str =~ s/setuid = yes/setuid = no/;
|
|
|
|
$str =~ s/bind/#bind/;
|
|
|
|
$str =~ s/mcast_join = .*/host = $master/;
|
2008-08-14 20:22:59 +00:00
|
|
|
my $pPairHash=xCAT_monitoring::monitorctrl->getMonServer($noderef);
|
2009-03-17 21:07:21 +00:00
|
|
|
if (ref($pPairHash) eq 'ARRAY') {
|
|
|
|
if ($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]=$pPairHash->[1];
|
|
|
|
$callback->($resp);
|
|
|
|
} else {
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: " . $pPairHash->[1]);
|
|
|
|
}
|
|
|
|
return (1, "");
|
|
|
|
}
|
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
#identification of this node
|
|
|
|
my @hostinfo=xCAT::Utils->determinehostname();
|
|
|
|
my $isSV=xCAT::Utils->isServiceNode();
|
|
|
|
my %iphash=();
|
|
|
|
foreach(@hostinfo) {$iphash{$_}=1;}
|
|
|
|
if (!$isSV) { $iphash{'noservicenode'}=1;}
|
2009-03-17 21:07:21 +00:00
|
|
|
|
|
|
|
# my @children;
|
2008-08-14 20:22:59 +00:00
|
|
|
foreach my $key (keys (%$pPairHash))
|
2009-03-17 21:07:21 +00:00
|
|
|
{ #opening for each
|
|
|
|
my @key_a=split(':', $key);
|
|
|
|
if (! $iphash{$key_a[0]}) { next; }
|
|
|
|
|
|
|
|
my $pattern = '^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})';
|
|
|
|
if ( $key_a[0]!~/$pattern/ )
|
2008-08-14 20:22:59 +00:00
|
|
|
{
|
2009-03-17 21:07:21 +00:00
|
|
|
my $cluster = $key_a[0];
|
|
|
|
if (-e "/etc/xCATSN")
|
|
|
|
{
|
|
|
|
$str =~ s/name = "unspecified"/name="$cluster"/;
|
|
|
|
}
|
2008-08-14 20:22:59 +00:00
|
|
|
}
|
2009-03-17 21:07:21 +00:00
|
|
|
|
|
|
|
} #closing for each
|
|
|
|
|
|
|
|
$str =~ s/name = "unspecified"/name="$hostname"/;
|
|
|
|
$str =~ s/mcast_join/# mcast_join/;
|
|
|
|
print FILE $str;
|
|
|
|
print FILE "# xCAT gmond settings done \n";
|
|
|
|
close(FILE1);
|
|
|
|
close(FILE);
|
2008-08-14 20:22:59 +00:00
|
|
|
`/bin/cp -f /etc/gmond.conf.tmp /etc/gmond.conf`;
|
2009-03-17 21:07:21 +00:00
|
|
|
|
|
|
|
# } #closing for each
|
|
|
|
|
|
|
|
} #closing if ?
|
|
|
|
|
|
|
|
} #closing if 3.0.7
|
2008-09-03 19:00:10 +00:00
|
|
|
|
2009-03-17 21:07:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
if ($scope)
|
|
|
|
{#opening if scope of confGmond
|
2008-11-07 13:59:27 +00:00
|
|
|
chomp(my $hostname = `hostname`);
|
2008-08-14 20:22:59 +00:00
|
|
|
my $pPairHash=xCAT_monitoring::monitorctrl->getMonServer($noderef);
|
2009-03-17 21:07:21 +00:00
|
|
|
if (ref($pPairHash) eq 'ARRAY') {
|
|
|
|
if ($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]=$pPairHash->[1];
|
|
|
|
$callback->($resp);
|
|
|
|
} else {
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: " . $pPairHash->[1]);
|
|
|
|
}
|
|
|
|
return (1, "");
|
|
|
|
}
|
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
#identification of this node
|
|
|
|
my @hostinfo=xCAT::Utils->determinehostname();
|
|
|
|
my $isSV=xCAT::Utils->isServiceNode();
|
|
|
|
my %iphash=();
|
|
|
|
foreach(@hostinfo) {$iphash{$_}=1;}
|
|
|
|
if (!$isSV) { $iphash{'noservicenode'}=1;}
|
2009-03-17 21:07:21 +00:00
|
|
|
|
|
|
|
my @children;
|
|
|
|
foreach my $key (keys (%$pPairHash))
|
2008-08-14 20:22:59 +00:00
|
|
|
{ #opening for each
|
2009-03-17 21:07:21 +00:00
|
|
|
my @key_a=split(':', $key);
|
|
|
|
if (! $iphash{$key_a[0]}) { next; }
|
|
|
|
my $mon_nodes=$pPairHash->{$key};
|
|
|
|
|
|
|
|
foreach(@$mon_nodes)
|
|
|
|
{ #opening foreach2
|
|
|
|
my $node=$_->[0];
|
|
|
|
my $nodetype=$_->[1];
|
|
|
|
#print "node=$node, nodetype=$nodetype\n";
|
|
|
|
if (($nodetype) && ($nodetype =~ /$::NODETYPE_OSI/))
|
|
|
|
{
|
|
|
|
push(@children,$node);
|
|
|
|
}
|
|
|
|
} #closing foreach2
|
|
|
|
|
|
|
|
my $node = join(',',@children);
|
|
|
|
my $res_cp = `XCATBYPASS=Y $::XCATROOT/bin/xdcp $node /install/postscripts/confGang /tmp 2>&1`;
|
|
|
|
if($?)
|
|
|
|
{ #openinf if ?
|
|
|
|
if($callback)
|
|
|
|
{
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: $res_cp";
|
|
|
|
$callback->($resp);
|
|
|
|
}
|
|
|
|
else { xCAT::MsgUtils->message('S', "Cannot copy confGang into /tmp: $res_cp \n"); }
|
|
|
|
} #closing if ?
|
|
|
|
|
|
|
|
|
|
|
|
my $res_conf;
|
|
|
|
if ( $key_a[0] =~ /noservicenode/ )
|
|
|
|
{
|
|
|
|
$res_conf=`XCATBYPASS=Y $::XCATROOT/bin/xdsh $node MONSERVER=$hostname MONMASTER=$key_a[1] /tmp/confGang 2>&1`;
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$res_conf=`XCATBYPASS=Y $::XCATROOT/bin/xdsh $node MONSERVER=$key_a[0] MONMASTER=$key_a[1] /tmp/confGang 2>&1`;
|
|
|
|
}
|
|
|
|
if($?)
|
|
|
|
{ #openinf if ?
|
|
|
|
if($callback)
|
|
|
|
{
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: $res_conf";
|
|
|
|
$callback->($resp);
|
|
|
|
}
|
|
|
|
else { xCAT::MsgUtils->message('S', "Cannot configure gmond in nodes: $res_conf \n"); }
|
|
|
|
} #closing if ?
|
|
|
|
} #closing for each
|
2008-08-14 20:22:59 +00:00
|
|
|
|
2009-03-17 21:07:21 +00:00
|
|
|
}#closing if scope
|
|
|
|
} # closing subroutine
|
2008-08-14 20:22:59 +00:00
|
|
|
|
|
|
|
#--------------------------------------------------------------
|
|
|
|
=head3 confGmetad
|
|
|
|
This function is called by the config() function. It configures the Gmetad
|
|
|
|
configuration files for the given nodes
|
|
|
|
Arguments:
|
|
|
|
p_nodes -- a pointer to an arrays of nodes to be added for monitoring. none means all.
|
|
|
|
scope -- the action scope, it indicates the node type the action will take place.
|
|
|
|
0 means localhost only.
|
|
|
|
2 means localhost and nodes,
|
|
|
|
callback -- the callback pointer for error and status displaying. It can be null.
|
2008-08-20 18:17:21 +00:00
|
|
|
Returns : none
|
2008-08-14 20:22:59 +00:00
|
|
|
=cut
|
|
|
|
#--------------------------------------------------------------
|
|
|
|
|
|
|
|
sub confGmetad
|
|
|
|
{
|
|
|
|
print "gangliamon:confGmetad called \n";
|
|
|
|
# no warnings;
|
|
|
|
my $noderef=shift;
|
|
|
|
if ($noderef =~ /xCAT_monitoring::gangliamon/) {
|
|
|
|
$noderef=shift;
|
|
|
|
}
|
|
|
|
my $scope=shift;
|
|
|
|
my $callback=shift;
|
|
|
|
|
|
|
|
my $localhost=hostname();
|
|
|
|
|
|
|
|
chomp(my $hostname = `hostname`);
|
2009-03-13 03:31:33 +00:00
|
|
|
if (-e "/etc/ganglia/gmetad.conf")
|
2008-09-03 19:00:10 +00:00
|
|
|
{ #opening if 3.1.0
|
|
|
|
`/bin/grep "xCAT gmetad settings done" /etc/ganglia/gmetad.conf`;
|
2008-08-14 20:22:59 +00:00
|
|
|
|
|
|
|
if($?)
|
2008-09-03 19:00:10 +00:00
|
|
|
{ #openinf if ?
|
|
|
|
if($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: $?";
|
|
|
|
$callback->($resp);
|
|
|
|
} else { xCAT::MsgUtils->message('S', "Gmetad not configured $? \n"); }
|
|
|
|
# backup the original file
|
|
|
|
`/bin/cp -f /etc/ganglia/gmetad.conf /etc/ganglia/gmetad.conf.orig`;
|
|
|
|
|
|
|
|
open(FILE1, "</etc/ganglia/gmetad.conf");
|
|
|
|
open(FILE, "+>/etc/ganglia/gmetad.conf.tmp");
|
|
|
|
|
|
|
|
while (readline(FILE1))
|
|
|
|
{
|
|
|
|
# print STDERR "READ = $_\n";
|
|
|
|
s/data_source/#data_source/g;
|
|
|
|
# print STDERR "POST-READ = $_\n";
|
|
|
|
print FILE $_;
|
|
|
|
}
|
|
|
|
close(FILE1);
|
|
|
|
close(FILE);
|
|
|
|
`/bin/cp -f /etc/ganglia/gmetad.conf.tmp /etc/ganglia/gmetad.conf`;
|
|
|
|
|
|
|
|
open(OUTFILE,"+>>/etc/ganglia/gmetad.conf")
|
|
|
|
or die ("Cannot open file \n");
|
|
|
|
print(OUTFILE "# Setting up GMETAD configuration file \n");
|
|
|
|
|
|
|
|
if (-e "/etc/xCATMN")
|
|
|
|
{
|
|
|
|
print(OUTFILE "data_source \"$hostname\" localhost \n");
|
|
|
|
}
|
|
|
|
my $noderef=xCAT_monitoring::monitorctrl->getMonHierarchy();
|
2009-03-17 21:07:21 +00:00
|
|
|
if (ref($noderef) eq 'ARRAY') {
|
|
|
|
if ($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]=$noderef->[1];
|
|
|
|
$callback->($resp);
|
|
|
|
} else {
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: " . $noderef->[1]);
|
|
|
|
}
|
|
|
|
return (1, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-03 19:00:10 +00:00
|
|
|
my @hostinfo=xCAT::Utils->determinehostname();
|
|
|
|
my $isSV=xCAT::Utils->isServiceNode();
|
|
|
|
my %iphash=();
|
|
|
|
foreach(@hostinfo) {$iphash{$_}=1;}
|
|
|
|
if (!$isSV) { $iphash{'noservicenode'}=1;}
|
|
|
|
|
|
|
|
my @children;
|
|
|
|
my $cluster;
|
|
|
|
foreach my $key (keys (%$noderef))
|
|
|
|
{
|
2009-03-17 21:07:21 +00:00
|
|
|
my @key_g=split(':', $key);
|
2008-09-03 19:00:10 +00:00
|
|
|
if (! $iphash{$key_g[0]}) { next;}
|
|
|
|
my $mon_nodes=$noderef->{$key};
|
|
|
|
my $pattern = '^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})';
|
|
|
|
if ( $key_g[0]!~/$pattern/ )
|
|
|
|
{
|
|
|
|
no warnings;
|
|
|
|
$cluster = $key_g[0];
|
|
|
|
}
|
|
|
|
foreach(@$mon_nodes)
|
|
|
|
{
|
|
|
|
my $node=$_->[0];
|
|
|
|
my $nodetype=$_->[1];
|
|
|
|
if (($nodetype) && ($nodetype =~ /$::NODETYPE_OSI/))
|
|
|
|
{
|
|
|
|
push(@children,$node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
my $num=@children;
|
|
|
|
if (-e "/etc/xCATSN")
|
|
|
|
{
|
|
|
|
for (my $i = 0; $i < $num; $i++)
|
|
|
|
{
|
|
|
|
print ( OUTFILE "data_source \"$cluster\" $children[ $i ] \n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (my $j = 0; $j < $num; $j++)
|
|
|
|
{
|
|
|
|
print ( OUTFILE "data_source \"$children[ $j ]\" $children[ $j ] \n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print(OUTFILE "# xCAT gmetad settings done \n");
|
|
|
|
close(OUTFILE);
|
|
|
|
|
|
|
|
} #closing if? loop
|
|
|
|
} # closing if 3.1.0
|
|
|
|
else
|
|
|
|
|
|
|
|
{#opening if 3.0.7
|
|
|
|
`/bin/grep "xCAT gmetad settings done" /etc/gmetad.conf`;
|
|
|
|
if($?)
|
2008-08-14 20:22:59 +00:00
|
|
|
{ #openinf if ?
|
|
|
|
if($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: $?";
|
|
|
|
$callback->($resp);
|
|
|
|
} else { xCAT::MsgUtils->message('S', "Gmetad not configured $? \n"); }
|
|
|
|
# backup the original file
|
|
|
|
`/bin/cp -f /etc/gmetad.conf /etc/gmetad.conf.orig`;
|
|
|
|
|
|
|
|
open(FILE1, "</etc/gmetad.conf");
|
|
|
|
open(FILE, "+>/etc/gmetad.conf.tmp");
|
|
|
|
|
|
|
|
while (readline(FILE1))
|
|
|
|
{
|
|
|
|
s/data_source/#data_source/g;
|
|
|
|
print FILE $_;
|
|
|
|
}
|
|
|
|
close(FILE1);
|
|
|
|
close(FILE);
|
|
|
|
`/bin/cp -f /etc/gmetad.conf.tmp /etc/gmetad.conf`;
|
|
|
|
|
|
|
|
open(OUTFILE,"+>>/etc/gmetad.conf")
|
|
|
|
or die ("Cannot open file \n");
|
|
|
|
print(OUTFILE "# Setting up GMETAD configuration file \n");
|
|
|
|
|
|
|
|
if (-e "/etc/xCATMN")
|
|
|
|
{
|
|
|
|
print(OUTFILE "data_source \"$hostname\" localhost \n");
|
|
|
|
}
|
|
|
|
my $noderef=xCAT_monitoring::monitorctrl->getMonHierarchy();
|
2009-03-17 21:07:21 +00:00
|
|
|
if (ref($noderef) eq 'ARRAY') {
|
|
|
|
if ($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]=$noderef->[1];
|
|
|
|
$callback->($resp);
|
|
|
|
} else {
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: " . $noderef->[1]);
|
|
|
|
}
|
|
|
|
return (1, "");
|
|
|
|
}
|
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
my @hostinfo=xCAT::Utils->determinehostname();
|
|
|
|
my $isSV=xCAT::Utils->isServiceNode();
|
|
|
|
my %iphash=();
|
|
|
|
foreach(@hostinfo) {$iphash{$_}=1;}
|
|
|
|
if (!$isSV) { $iphash{'noservicenode'}=1;}
|
|
|
|
|
|
|
|
my @children;
|
|
|
|
my $cluster;
|
|
|
|
foreach my $key (keys (%$noderef))
|
|
|
|
{
|
2009-03-17 21:07:21 +00:00
|
|
|
my @key_g=split(':', $key);
|
2008-08-14 20:22:59 +00:00
|
|
|
# print "a[0] is: $key_g[0] \n";
|
|
|
|
if (! $iphash{$key_g[0]}) { next;}
|
|
|
|
my $mon_nodes=$noderef->{$key};
|
|
|
|
my $pattern = '^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})';
|
|
|
|
if ( $key_g[0]!~/$pattern/ )
|
|
|
|
{
|
|
|
|
no warnings;
|
|
|
|
$cluster = $key_g[0];
|
|
|
|
}
|
|
|
|
foreach(@$mon_nodes)
|
|
|
|
{
|
|
|
|
my $node=$_->[0];
|
|
|
|
my $nodetype=$_->[1];
|
|
|
|
if (($nodetype) && ($nodetype =~ /$::NODETYPE_OSI/))
|
|
|
|
{
|
|
|
|
push(@children,$node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
my $num=@children;
|
|
|
|
if (-e "/etc/xCATSN")
|
|
|
|
{
|
|
|
|
for (my $i = 0; $i < $num; $i++)
|
|
|
|
{
|
|
|
|
print ( OUTFILE "data_source \"$cluster\" $children[ $i ] \n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (my $j = 0; $j < $num; $j++)
|
|
|
|
{
|
|
|
|
print ( OUTFILE "data_source \"$children[ $j ]\" $children[ $j ] \n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print(OUTFILE "# xCAT gmetad settings done \n");
|
|
|
|
close(OUTFILE);
|
|
|
|
|
|
|
|
} #closing if? loop
|
|
|
|
|
2008-09-03 19:00:10 +00:00
|
|
|
} #closing if 3.0.7
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
} # closing subrouting
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------
|
|
|
|
=head3 deconfig
|
|
|
|
This function de-configures the cluster for the given nodes. This function is called
|
|
|
|
when mondecfg command is issued by the user. This function restores the original Gmond
|
|
|
|
and Gmetad configuration files by calling the deconfGmond and deconfGmetad functions
|
|
|
|
respectively.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
p_nodes -- a pointer to an arrays of nodes to be removed for monitoring. none means all.
|
|
|
|
scope -- the action scope, it indicates the node type the action will take place.
|
|
|
|
0 means local host only.
|
|
|
|
2 means both local host and nodes,
|
|
|
|
callback -- the callback pointer for error and status displaying. It can be null.
|
2008-08-20 18:17:21 +00:00
|
|
|
Returns: none
|
2008-08-14 20:22:59 +00:00
|
|
|
=cut
|
|
|
|
#--------------------------------------------------------------
|
|
|
|
sub deconfig
|
|
|
|
{
|
|
|
|
print "gangliamon:deconfig called\n";
|
|
|
|
my $noderef=shift;
|
|
|
|
if ($noderef =~ /xCAT_monitoring::gangliamon/) {
|
|
|
|
$noderef=shift;
|
|
|
|
}
|
|
|
|
my $scope=shift;
|
|
|
|
my $callback=shift;
|
|
|
|
|
|
|
|
deconfGmond($noderef,$scope,$callback);
|
|
|
|
deconfGmetad($noderef,$scope,$callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------
|
|
|
|
=head3 deconfGmond
|
2008-08-18 17:45:51 +00:00
|
|
|
This function is called by the deconfig() function. It deconfigures the Gmetad
|
2008-08-14 20:22:59 +00:00
|
|
|
configuration files for the given nodes
|
|
|
|
Arguments:
|
|
|
|
p_nodes -- a pointer to an arrays of nodes to be added for monitoring. none means all.
|
|
|
|
scope -- the action scope, it indicates the node type the action will take place.
|
|
|
|
0 means localhost only.
|
|
|
|
2 means localhost and nodes,
|
|
|
|
callback -- the callback pointer for error and status displaying. It can be null.
|
2008-08-20 18:17:21 +00:00
|
|
|
Returns:none
|
2008-08-14 20:22:59 +00:00
|
|
|
=cut
|
|
|
|
#--------------------------------------------------------------
|
|
|
|
|
|
|
|
sub deconfGmond
|
|
|
|
{
|
|
|
|
print "gangliamon:deconfGmond called \n";
|
|
|
|
no warnings;
|
|
|
|
my $noderef=shift;
|
|
|
|
if ($noderef =~ /xCAT_monitoring::gangliamon/) {
|
|
|
|
$noderef=shift;
|
|
|
|
}
|
|
|
|
my $scope=shift;
|
|
|
|
my $callback=shift;
|
|
|
|
|
|
|
|
my $localhost=hostname();
|
|
|
|
|
2009-03-13 03:31:33 +00:00
|
|
|
if (-e "/etc/ganglia/gmond.conf")
|
2008-09-03 19:00:10 +00:00
|
|
|
{ #opening if V3.1.0
|
|
|
|
`/bin/cp -f /etc/ganglia/gmond.conf /etc/ganglia/gmond.conf.save`;
|
|
|
|
my $decon_gmond=`/bin/cp -f /etc/ganglia/gmond.conf.orig /etc/ganglia/gmond.conf`;
|
|
|
|
if($?)
|
2008-08-14 20:22:59 +00:00
|
|
|
{ #openinf if ?
|
|
|
|
if($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost:$decon_gmond";
|
|
|
|
$callback->($resp);
|
|
|
|
} else { xCAT::MsgUtils->message('S', "Gmond not deconfigured $decon_gmond \n"); }
|
2008-09-03 19:00:10 +00:00
|
|
|
} # closing if ?
|
|
|
|
} #closing if V3.1.0
|
|
|
|
|
|
|
|
else
|
|
|
|
{ #opening V3.0.7
|
|
|
|
`/bin/cp -f /etc/gmond.conf /etc/gmond.conf.save`;
|
|
|
|
my $decon_gmond=`/bin/cp -f /etc/gmond.conf.orig /etc/gmond.conf`;
|
|
|
|
if($?)
|
|
|
|
{ #openinf if ?
|
|
|
|
if($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost:$decon_gmond";
|
|
|
|
$callback->($resp);
|
|
|
|
} else { xCAT::MsgUtils->message('S', "Gmond not deconfigured $decon_gmond \n"); }
|
|
|
|
} # closing if?
|
|
|
|
} #closing V3.0.7
|
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
if ($scope)
|
|
|
|
{#opening if scope of confGmond
|
|
|
|
my $pPairHash=xCAT_monitoring::monitorctrl->getMonServer($noderef);
|
2009-03-17 21:07:21 +00:00
|
|
|
if (ref($pPairHash) eq 'ARRAY') {
|
|
|
|
if ($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]=$pPairHash->[1];
|
|
|
|
$callback->($resp);
|
|
|
|
} else {
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: " . $pPairHash->[1]);
|
|
|
|
}
|
|
|
|
return (1, "");
|
|
|
|
}
|
2008-08-14 20:22:59 +00:00
|
|
|
|
|
|
|
#identification of this node
|
|
|
|
my @hostinfo=xCAT::Utils->determinehostname();
|
|
|
|
my $isSV=xCAT::Utils->isServiceNode();
|
|
|
|
my %iphash=();
|
|
|
|
foreach(@hostinfo) {$iphash{$_}=1;}
|
|
|
|
if (!$isSV) { $iphash{'noservicenode'}=1;}
|
|
|
|
|
2009-03-17 21:07:21 +00:00
|
|
|
my @children;
|
|
|
|
foreach my $key (keys (%$pPairHash))
|
2008-08-14 20:22:59 +00:00
|
|
|
{ #opening for each
|
2009-03-17 21:07:21 +00:00
|
|
|
my @key_a=split(':', $key);
|
|
|
|
if (! $iphash{$key_a[0]}) { next; }
|
|
|
|
my $mon_nodes=$pPairHash->{$key};
|
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
foreach(@$mon_nodes)
|
|
|
|
{ #opening foreach2
|
|
|
|
my $node=$_->[0];
|
|
|
|
my $nodetype=$_->[1];
|
|
|
|
if (($nodetype) && ($nodetype =~ /$::NODETYPE_OSI/))
|
|
|
|
{
|
|
|
|
push(@children,$node);
|
|
|
|
}
|
|
|
|
} #closing foreach2
|
|
|
|
|
|
|
|
my $node = join(',',@children);
|
2009-03-13 06:37:44 +00:00
|
|
|
if (-e "/etc/ganglia/gmond.conf")
|
2008-09-03 19:00:10 +00:00
|
|
|
{ # opening if V3.1.0
|
|
|
|
my $res_sv = `XCATBYPASS=Y $::XCATROOT/bin/xdsh $node /bin/cp -f /etc/ganglia/gmond.conf /etc/ganglia/gmond.conf.save`;
|
2008-08-14 20:22:59 +00:00
|
|
|
|
2008-09-03 19:00:10 +00:00
|
|
|
my $res_cp = `XCATBYPASS=Y $::XCATROOT/bin/xdsh $node /bin/cp -f /etc/ganglia/gmond.conf.orig /etc/ganglia/gmond.conf`;
|
|
|
|
if($?)
|
|
|
|
{ #openinf if ?
|
|
|
|
if($callback)
|
|
|
|
{
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: $res_cp";
|
|
|
|
$callback->($resp);
|
|
|
|
}
|
|
|
|
else { xCAT::MsgUtils->message('S', "Gmond not deconfigured: $res_cp \n"); }
|
|
|
|
} #closing if ?
|
|
|
|
} # closing if V3.1.0
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
my $res_sv = `XCATBYPASS=Y $::XCATROOT/bin/xdsh $node /bin/cp -f /etc/gmond.conf /etc/gmond.conf.save`;
|
|
|
|
|
|
|
|
my $res_cp = `XCATBYPASS=Y $::XCATROOT/bin/xdsh $node /bin/cp -f /etc/gmond.conf.orig /etc/gmond.conf`;
|
|
|
|
if($?)
|
2008-08-14 20:22:59 +00:00
|
|
|
{ #openinf if ?
|
|
|
|
if($callback)
|
|
|
|
{
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: $res_cp";
|
|
|
|
$callback->($resp);
|
|
|
|
}
|
|
|
|
else { xCAT::MsgUtils->message('S', "Gmond not deconfigured: $res_cp \n"); }
|
|
|
|
} #closing if ?
|
2008-09-03 19:00:10 +00:00
|
|
|
} # closing if V3.1.0
|
2008-08-14 20:22:59 +00:00
|
|
|
} # closing for each
|
|
|
|
} # closing if scope
|
|
|
|
|
|
|
|
} # closing subroutine
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------
|
|
|
|
=head3 deconfGmetad
|
|
|
|
This function is called by the deconfig() function. It deconfigures the Gmetad
|
|
|
|
configuration files for the given nodes
|
|
|
|
Arguments:
|
|
|
|
p_nodes -- a pointer to an arrays of nodes to be added for monitoring. none means all.
|
|
|
|
scope -- the action scope, it indicates the node type the action will take place.
|
|
|
|
0 means localhost only.
|
|
|
|
2 means localhost and nodes,
|
|
|
|
callback -- the callback pointer for error and status displaying. It can be null.
|
2008-08-20 18:17:21 +00:00
|
|
|
Returns:none
|
2008-08-14 20:22:59 +00:00
|
|
|
=cut
|
|
|
|
#--------------------------------------------------------------
|
|
|
|
|
|
|
|
sub deconfGmetad
|
|
|
|
{
|
|
|
|
print "gangliamon:deconfGmetad called \n";
|
|
|
|
no warnings;
|
|
|
|
my $noderef=shift;
|
|
|
|
if ($noderef =~ /xCAT_monitoring::gangliamon/) {
|
|
|
|
$noderef=shift;
|
|
|
|
}
|
|
|
|
my $scope=shift;
|
|
|
|
my $callback=shift;
|
|
|
|
|
|
|
|
my $localhost=hostname();
|
|
|
|
|
2009-03-13 03:31:33 +00:00
|
|
|
if (-e "/etc/ganglia/gmetad.conf")
|
2008-09-03 19:00:10 +00:00
|
|
|
{ #opening V3.1.0
|
|
|
|
`/bin/cp -f /etc/ganglia/gmetad.conf /etc/ganglia/gmetad.conf.save`;
|
|
|
|
my $decon_gmetad=`/bin/cp -f /etc/ganglia/gmetad.conf.orig /etc/ganglia/gmetad.conf`;
|
2008-08-14 20:22:59 +00:00
|
|
|
if($?)
|
|
|
|
{ #openinf if ?
|
|
|
|
if($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: $decon_gmetad";
|
|
|
|
$callback->($resp);
|
|
|
|
} else { xCAT::MsgUtils->message('S', "Gmetadd not deconfigured $decon_gmetad \n"); }
|
|
|
|
}
|
2008-09-03 19:00:10 +00:00
|
|
|
} #closing V3.1.0
|
|
|
|
|
|
|
|
else
|
|
|
|
{ #opening V3.0.7
|
|
|
|
`/bin/cp -f /etc/gmetad.conf /etc/gmetad.conf.save`;
|
|
|
|
my $decon_gmetad=`/bin/cp -f /etc/gmetad.conf.orig /etc/gmetad.conf`;
|
|
|
|
if($?)
|
|
|
|
{ #openinf if ?
|
|
|
|
if($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: $decon_gmetad";
|
|
|
|
$callback->($resp);
|
|
|
|
} else { xCAT::MsgUtils->message('S', "Gmetadd not deconfigured $decon_gmetad \n"); }
|
|
|
|
}
|
|
|
|
} #closing 3.0.7
|
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
} # closing subroutine
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
=head3 stop
|
|
|
|
This function gets called by the monitorctrl module when
|
|
|
|
xcatd stops or when monstop command is issued by the user.
|
|
|
|
It stops the monitoring on all nodes, stops
|
|
|
|
the daemons and does necessary cleanup process for the
|
|
|
|
Ganglia monitoring.
|
|
|
|
Arguments:
|
|
|
|
p_nodes -- a pointer to an arrays of nodes to be stoped for monitoring. null means all.
|
|
|
|
scope -- the action scope, it indicates the node type the action will take place.
|
|
|
|
0 means localhost only.
|
|
|
|
2 means both monservers and nodes,
|
|
|
|
callback -- the callback pointer for error and status displaying. It can be null.
|
|
|
|
Returns:
|
|
|
|
(return code, message)
|
|
|
|
if the callback is set, use callback to display the status and error.
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
sub stop
|
|
|
|
{ # starting sub routine
|
|
|
|
print "gangliamon::stop called\n";
|
|
|
|
my $noderef=shift;
|
|
|
|
if ($noderef =~ /xCAT_monitoring::gangliamon/)
|
|
|
|
{
|
|
|
|
$noderef=shift;
|
|
|
|
}
|
|
|
|
my $scope=shift;
|
|
|
|
my $callback=shift;
|
|
|
|
my $localhost=hostname();
|
2008-11-11 15:28:54 +00:00
|
|
|
my $OS=`uname`;
|
|
|
|
my $res_gmond;
|
|
|
|
if ( $OS =~ /AIX/ )
|
|
|
|
{
|
|
|
|
$res_gmond = `/etc/rc.d/init.d/gmond stop 2>&1`;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$res_gmond = `/etc/init.d/gmond stop 2>&1`;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($?)
|
2008-08-14 20:22:59 +00:00
|
|
|
{
|
|
|
|
if ($callback)
|
|
|
|
{
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: Ganglia Gmond not stopped successfully: $res_gmond \n";
|
|
|
|
$callback->($resp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: $res_gmond \n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return(1,"Ganglia Gmond not stopped successfully. \n");
|
|
|
|
}
|
|
|
|
|
2008-11-11 15:28:54 +00:00
|
|
|
my $res_gmetad;
|
|
|
|
if ( $OS =~ /AIX/ )
|
|
|
|
{
|
|
|
|
$res_gmetad = `/etc/rc.d/init.d/gmetad stop 2>&1`;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$res_gmetad = `/etc/init.d/gmetad stop 2>&1`;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($?)
|
2008-08-14 20:22:59 +00:00
|
|
|
{
|
|
|
|
if ($callback)
|
|
|
|
{
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: Ganglia Gmetad not stopped successfully:$res_gmetad \n";
|
|
|
|
$callback->($resp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: $res_gmetad \n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return(1,"Ganglia Gmetad not stopped successfully. \n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-03-17 21:07:21 +00:00
|
|
|
if ($scope) { #opening if scope
|
|
|
|
my $OS=`uname`;
|
|
|
|
my $pPairHash=xCAT_monitoring::monitorctrl->getMonServer($noderef);
|
|
|
|
if (ref($pPairHash) eq 'ARRAY') {
|
|
|
|
if ($callback) {
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]=$pPairHash->[1];
|
|
|
|
$callback->($resp);
|
|
|
|
} else {
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: " . $pPairHash->[1]);
|
|
|
|
}
|
|
|
|
return (1, "");
|
|
|
|
}
|
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
#identification of this node
|
|
|
|
my @hostinfo=xCAT::Utils->determinehostname();
|
|
|
|
my $isSV=xCAT::Utils->isServiceNode();
|
|
|
|
my %iphash=();
|
|
|
|
foreach(@hostinfo) {$iphash{$_}=1;}
|
|
|
|
if (!$isSV) { $iphash{'noservicenode'}=1;}
|
|
|
|
|
|
|
|
my @children;
|
|
|
|
foreach my $key (keys (%$pPairHash))
|
|
|
|
{ #opening foreach1
|
2009-03-17 21:07:21 +00:00
|
|
|
my @key_a=split(':', $key);
|
|
|
|
if (! $iphash{$key_a[0]}) { next; }
|
2008-08-14 20:22:59 +00:00
|
|
|
my $mon_nodes=$pPairHash->{$key};
|
|
|
|
|
|
|
|
foreach(@$mon_nodes)
|
|
|
|
{ #opening foreach2
|
|
|
|
my $node=$_->[0];
|
|
|
|
my $nodetype=$_->[1];
|
|
|
|
if (($nodetype) && ($nodetype =~ /$::NODETYPE_OSI/))
|
|
|
|
{
|
|
|
|
push(@children,$node);
|
|
|
|
}
|
|
|
|
} #closing foreach2
|
|
|
|
} #closing foreach1
|
2009-03-31 09:44:14 +00:00
|
|
|
my $result = undef;
|
|
|
|
my $rec = undef;
|
|
|
|
if( exists($children[0]) ){
|
|
|
|
$rec = join(',',@children);
|
|
|
|
}
|
|
|
|
if($rec){
|
|
|
|
if ( $OS =~ /AIX/ )
|
|
|
|
{
|
|
|
|
$result = `XCATBYPASS=Y $::XCATROOT/bin/xdsh $rec /etc/rc.d/init.d/gmond stop 2>&1`;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = `XCATBYPASS=Y $::XCATROOT/bin/xdsh $rec /etc/init.d/gmond stop 2>&1`;
|
|
|
|
}
|
2008-11-11 15:28:54 +00:00
|
|
|
}
|
|
|
|
|
2008-08-14 20:22:59 +00:00
|
|
|
if ($result)
|
|
|
|
{
|
|
|
|
if ($callback)
|
|
|
|
{
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: $result\n";
|
|
|
|
$callback->($resp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xCAT::MsgUtils->message('S', "[mon]: $result\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} #closing if scope
|
|
|
|
|
|
|
|
if ($callback)
|
|
|
|
{
|
|
|
|
my $resp={};
|
|
|
|
$resp->{data}->[0]="$localhost: stopped. \n";
|
|
|
|
$callback->($resp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0, "stopped");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
=head3 supportNodeStatusMon
|
|
|
|
This function is called by the monitorctrl module to check
|
|
|
|
if Ganglia can help monitoring and returning the node status.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
none
|
|
|
|
Returns:
|
|
|
|
1
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
sub supportNodeStatusMon {
|
|
|
|
#print "gangliamon::supportNodeStatusMon called\n";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
=head3 startNodeStatusMon
|
|
|
|
This function is called by the monitorctrl module to tell
|
|
|
|
Ganglia to start monitoring the node status and feed them back
|
|
|
|
to xCAT. Ganglia will start setting up the condition/response
|
|
|
|
to monitor the node status changes.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
None.
|
|
|
|
Returns:
|
|
|
|
(return code, message)
|
|
|
|
|
|
|
|
=cut
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
sub startNodeStatusMon {
|
|
|
|
#print "gangliamon::startNodeStatusMon called\n";
|
|
|
|
return (0, "started");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
=head3 stopNodeStatusMon
|
|
|
|
This function is called by the monitorctrl module to tell
|
|
|
|
Ganglia to stop feeding the node status info back to xCAT. It will
|
|
|
|
stop the condition/response that is monitoring the node status.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
none
|
|
|
|
Returns:
|
|
|
|
(return code, message)
|
|
|
|
=cut
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
sub stopNodeStatusMon {
|
|
|
|
#print "gangliamon::stopNodeStatusMon called\n";
|
|
|
|
return (0, "stopped");
|
|
|
|
}
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
=head3 getDiscription
|
|
|
|
This function returns the detailed description of the plugin inluding the
|
|
|
|
valid values for its settings in the monsetting tabel.
|
|
|
|
Arguments:
|
|
|
|
none
|
|
|
|
Returns:
|
|
|
|
The description.
|
|
|
|
=cut
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
sub getDescription
|
|
|
|
{
|
|
|
|
return "Description: This plugin will help interface the xCat cluster with
|
|
|
|
Gangliam monitoring software \n";
|
|
|
|
}
|
|
|
|
|
2008-09-16 13:55:31 +00:00
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
=head3 getPostscripts
|
|
|
|
This function returns the postscripts needed for the nodes.
|
|
|
|
Arguments: none
|
|
|
|
Returns:
|
|
|
|
The the postscripts. It a pointer to an array with the node group names as the keys
|
|
|
|
and the comma separated poscript names as the value. For example:
|
|
|
|
{service=>"cmd1,cmd2", xcatdefaults=>"cmd3,cmd4"} where xcatdefults is a group
|
|
|
|
of all nodes including the service nodes.
|
|
|
|
=cut
|
|
|
|
#--------------------------------------------------------------------------------
|
|
|
|
sub getPostscripts {
|
|
|
|
my $ret={};
|
|
|
|
$ret->{compute}="confGang";
|
|
|
|
return $ret;
|
|
|
|
}
|