From 4d56dcdd03b4e6e9ce2686d4bc642a87cfb23df9 Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Feb 24 2011 01:59:28 +0000 Subject: Bug 625424 - repl-monitor.pl doesn't work in hub node https://bugzilla.redhat.com/show_bug.cgi?id=625424 Description: repl-monitor.pl has been designed to display the entire replication topology. This patch allows to show the subset of the topology starting from the specified hub. --- diff --git a/ldap/admin/src/scripts/repl-monitor.pl.in b/ldap/admin/src/scripts/repl-monitor.pl.in index b8e6d2d..89b777c 100755 --- a/ldap/admin/src/scripts/repl-monitor.pl.in +++ b/ldap/admin/src/scripts/repl-monitor.pl.in @@ -511,28 +511,45 @@ sub process_suppliers my ($ridx, $mid, $maxcsn); $mid = ""; + $ismaster = 0; $last_sidx = -1; # global variable for print html page for ($ridx = 0; $ridx <= $#allreplicas; $ridx++) { - # Skip consumers and hubs - next if $allreplicas[$ridx] !~ /:master:(\d+):/i; - $mid = $1; + # Handle masters and hubs + if ($allreplicas[$ridx] =~ /:master:(\d+):/i) { + $mid = $1; - # Skip replicas without agreements defined yet - next if (! grep {$_->{ridx} == $ridx} @allagreements); + # Skip replicas without agreements defined yet + next if (! grep {$_->{ridx} == $ridx} @allagreements); - $maxcsn = &print_master_header ($ridx, $mid); - if ( "$maxcsn" != "none" ) { - &print_consumer_header (); - &print_consumers ($ridx, $mid); + $maxcsn = &print_master_header ($ridx, $mid); + if ( "$maxcsn" != "none" ) { + &print_consumer_header (); + &print_consumers ($ridx, $mid); + } + $ismaster = 1; + } elsif (($ismaster == 0) && ($allreplicas[$ridx] =~ /:hub:(\d+):/i)) { + $mid = $1; + + # Skip replicas without agreements defined yet + next if (! grep {$_->{ridx} == $ridx} @allagreements); + + foreach $key (keys %allruvs) { + if ( $key =~ /$ridx:/) { + my ($myridx, $mymid) = split ( /:/, "$key" ); + $maxcsn = &print_hub_header($myridx, $mymid); + &print_consumer_header (); + &print_consumers ($myridx, $mymid); + } + } } &print_supplier_end; } if ($mid eq "") { - print "

The server is not a master or it has no replication agreement\n"; + print "

The server is not a master or a hub or it has no replication agreement\n"; } } @@ -544,6 +561,10 @@ sub print_master_header my ($maxcsn) = &to_string_csn ($maxcsnval); my ($sidx, $replicaroot, $replicatype, $serverid) = split (/:/, $allreplicas[$ridx]); + if ( $maxcsn == "" ) { + return $maxcsn; + } + # Print the master name if ( $last_sidx != $sidx ) { my ($ldapurl) = &get_ldap_url ($sidx, $sidx); @@ -570,6 +591,40 @@ sub print_master_header return $maxcsn; } +sub print_hub_header +{ + my ($ridx, $mid) = @_; + my ($myruv) = $allruvs {"$ridx:$mid"}; + my ($maxcsnval) = split ( /;/, "$myruv" ); + my ($maxcsn) = &to_string_csn ($maxcsnval); + my ($sidx, $replicaroot, $replicatype, $serverid) = split (/:/, $allreplicas[$ridx]); + + # Print the master name + if ( $last_sidx != $sidx ) { + my ($ldapurl) = &get_ldap_url ($sidx, $sidx); + &print_legend if ( $last_sidx < 0); + print "


\n"; + print "\n

\n"; + print "Hub:  $ldapurl
\n"; + $last_sidx = $sidx; + } + + # Print the current replica info onthe master + print "\n

\n"; + + print "\n
\n"; + print "Replica ID: "; + print "$serverid\n"; + + print "Replica Root: "; + print "$replicaroot\n"; + + print "Max CSN: "; + print "$maxcsn\n"; + + return $maxcsn; +} + sub print_consumer_header { #Print the header of consumer