diff --git a/xCAT-server/lib/xcat/monitoring/gangliamon.pm b/xCAT-server/lib/xcat/monitoring/gangliamon.pm index 948eda03d..3df914d62 100755 --- a/xCAT-server/lib/xcat/monitoring/gangliamon.pm +++ b/xCAT-server/lib/xcat/monitoring/gangliamon.pm @@ -312,39 +312,46 @@ sub confGmond { return (0); } - my @raw_data = ; - close(CONF); - my $str = join( '', @raw_data ); - $str =~ s/setuid = yes/setuid = no/; - if ( !( $str =~ m/#bind/ ) ) { - $str =~ s/bind/#bind/; # Comment out bind - } - $str =~ s/mcast_join = .*/host = $hostname/; - - foreach my $key ( keys(%$pPairHash) ) { - my @key_a = split( ':', $key ); - if ( !$iphash{ $key_a[0] } ) { - next; + my $hasdone_udp_send_channel; + while () { + my $str = $_; + $str =~ s/setuid = yes/setuid = no/; + if ( $str =~ /^\s*bind / ) { + $str =~ s/bind/#bind/; # Comment out bind } - - my $pattern = '^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'; - if ( $key_a[0] !~ /$pattern/ ) { - my $cluster = $key_a[0]; - if ( -e "/etc/xCATSN" ) { - $str =~ s/name = "unspecified"/name="$cluster"/; + + # replace the mcast_join in the udp_send_channel section + if (!$hasdone_udp_send_channel && $str =~ /^\s*mcast_join =/) { + $str =~ s/mcast_join = .*/host = $hostname/; + $hasdone_udp_send_channel = 1; + } + + foreach my $key ( keys(%$pPairHash) ) { + 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/ ) { + my $cluster = $key_a[0]; + if ( -e "/etc/xCATSN" ) { + $str =~ s/name = "unspecified"/name="$cluster"/; + } } } - } - - $str =~ s/name = "unspecified"/name="$hostname"/; - - if ( !( $str =~ m/#mcast_join/ ) ) { - $str =~ s/mcast_join/#mcast_join/; # Comment out mcast_join - } - $str =~ s/# xCAT gmond settings done//; # Remove old message - print FILE $str; + $str =~ s/name = "unspecified"/name="$hostname"/; + + if ( $hasdone_udp_send_channel && $str =~ m/^\s*mcast_join/ ) { + $str =~ s/mcast_join/#mcast_join/; # Comment out mcast_join in the udp_recv_channel section + } + + $str =~ s/# xCAT gmond settings done//; # Remove old message + print FILE $str; + } print FILE "# xCAT gmond settings done\n"; + close(CONF); close(FILE); if ($scope) { @@ -515,7 +522,7 @@ sub confGmetad { } else { for ( my $j = 0 ; $j < $num ; $j++ ) { print( OUTFILE - "data_source \"$children[ $j ]\" $children[ $j ]:8651 \n" + "data_source \"$children[ $j ]\" $children[ $j ] \n" ); } } diff --git a/xCAT/postscripts/confGang b/xCAT/postscripts/confGang index 1ca339421..e5aa3c97f 100755 --- a/xCAT/postscripts/confGang +++ b/xCAT/postscripts/confGang @@ -85,10 +85,10 @@ gmond_conf_old="/etc/gmond.conf" /bin/cp -f $gmond_conf /etc/ganglia/gmond.conf.orig sed -i 's/setuid = yes/setuid = no/1' $gmond_conf sed -i 's/name = "unspecified"/name='$CLUSTER'/1' $gmond_conf - sed -e "1,40s/mcast_join = .*/host = $MASTER/" $gmond_conf > /etc/temp.conf + sed -e "1,50s/^ *mcast_join = .*/host = $MASTER/" $gmond_conf > /etc/temp.conf /bin/cp -f /etc/temp.conf $gmond_conf - sed -i 's/mcast_join/#/g' $gmond_conf - sed -i 's/bind/#/g' $gmond_conf + sed -i 's/^ *mcast_join/#mcast_join/g' $gmond_conf + sed -i 's/^ *bind/#bind/g' $gmond_conf echo "# xCAT gmond settings done sh" >> $gmond_conf fi fi