ldap/admin/src/scripts/repl-monitor.pl.in | 75 ++++++++++++++++++++++++++----
1 file changed, 65 insertions(+), 10 deletions(-)
New commits:
commit 4d56dcdd03b4e6e9ce2686d4bc642a87cfb23df9
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Feb 23 15:18:45 2011 -0800
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 "<p>The server is not a master or it has no replication
agreement\n";
+ print "<p>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 "<p><p><hr><p>\n";
+ print "\n<p><center class=page-subtitle><font
color=#0099cc>\n";
+ print "Hub:  $ldapurl</center>\n";
+ $last_sidx = $sidx;
+ }
+
+ # Print the current replica info onthe master
+ print "\n<p><table border=0 cellspacing=1 cellpadding=6 cols=10 width=100%
class=bgColor9>\n";
+
+ print "\n<tr><td colspan=10><center>\n";
+ print "<font class=areatitle>Replica ID: </font>";
+ print "<font class=text28>$serverid</font>\n";
+
+ print "<font class=areatitle>Replica Root: </font>";
+ print "<font class=text28>$replicaroot</font>\n";
+
+ print "<font class=areatitle>Max CSN: </font>";
+ print "<font class=text28>$maxcsn</font>\n";
+
+ return $maxcsn;
+}
+
sub print_consumer_header
{
#Print the header of consumer