From 0fe8f374db9df553bbd494952511f6546ab52155 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Jun 28 2016 20:19:57 +0000 Subject: Ticket 47538 - Fix repl-monitor color and lag times Bug Description: Colors do not match the legend, and when the supplier or consumer max csns are not available, the lag time is displayed incorrectly. Fix Description: The color hash table needed to be sorted before processing, and we were not properly detecting the "Unavailable" state of a replica which lead to the odd lag times. Also added the string "Unavailable" for uninitialized values which allowed for a cleaner report when replicas are offline. Updated the man page as well. https://fedorahosted.org/389/ticket/47538 Reviewed by: nhosoi(Thanks!) (cherry picked from commit 34c929353280b93eebe214f1c21f5b788aff1c39) --- diff --git a/ldap/admin/src/scripts/repl-monitor.pl.in b/ldap/admin/src/scripts/repl-monitor.pl.in index eca3db0..88655ff 100755 --- a/ldap/admin/src/scripts/repl-monitor.pl.in +++ b/ldap/admin/src/scripts/repl-monitor.pl.in @@ -597,7 +597,7 @@ sub process_suppliers # Skip replicas without agreements defined yet next if (! grep {$_->{ridx} == $ridx} @allagreements); $maxcsn = &print_master_header ($ridx, $mid); - if ( "$maxcsn" ne "none" ) { + if ( "$maxcsn" ne "Unavailable" ) { &print_consumer_header (); &print_consumers ($ridx, $mid); } @@ -755,12 +755,12 @@ sub print_consumers my ($c_maxcsn, $c_maxcsn_str, $c_lastmodified, $c_sidx, $lag, $markcolor); my ($c_replicaroot, $c_replicatype); my ($first_entry, $s_ldapurl, $c_ldapurl); - my $supplier_maxcsn = "_"; + my $supplier_maxcsn = "Unavailable"; my ($nrows); my ($found); undef @ouragreements; - $c_lastmodified = ""; + $c_lastmodified = "Unavailable"; # Collect all the consumer replicas for the current master replica push (@consumers, $m_ridx); @@ -791,18 +791,20 @@ sub print_consumers if ($c_ridx >= 0) { $myruv = $allruvs {"$c_ridx:$mid"}; - ($c_maxcsn, $c_lastmodified) = split ( /;/, $myruv ); - ($c_sidx, $c_replicaroot, $c_replicatype) = split (/:/, $allreplicas[$c_ridx]); - $c_replicaroot = "same as master" if $m_replicaroot eq $c_replicaroot; + if ($myruv) { + ($c_maxcsn, $c_lastmodified) = split ( /;/, $myruv ); + ($c_sidx, $c_replicaroot, $c_replicatype) = split (/:/, $allreplicas[$c_ridx]); + $c_replicaroot = "same as master" if $m_replicaroot eq $c_replicaroot; + } } else { # $c_ridx is actually -$c_sidx when c is not available $c_sidx = -$c_ridx; - $c_maxcsn_str = "_"; + $c_maxcsn_str = "Unavailable"; $lag = "n/a"; $markcolor = "red"; - $c_replicaroot = "_"; - $c_replicatype = "_"; + $c_replicaroot = "Unavailable"; + $c_replicatype = "Unavailable"; } $nrows = 0; @@ -933,7 +935,7 @@ sub get_supplier_maxcsn { my ($ridx, $s, $cn, $h, $p) = @_; my $decimalcsn; - my $csn = ""; + my $csn = "Unavailable"; # normalize suffix $s =~ s/ //; $s =~ lc $s; @@ -945,7 +947,7 @@ sub get_supplier_maxcsn last; } } - if($csn ne ""){ + if($csn && $csn ne "Unavailable"){ $decimalcsn = &to_decimal_csn ($csn); return "$csn:$decimalcsn"; } @@ -967,11 +969,16 @@ sub cacl_time_lag $supplier_csn_str = &to_string_csn ($s_maxcsn); $csn_str = &to_string_csn ($c_maxcsn); - if ($s_maxcsn && !$c_maxcsn) { + if ((!$s_maxcsn || $s_maxcsn eq "Unavailable") && + (!$c_maxcsn || $c_maxcsn eq "Unavailable")) { + $lag_str = "?:??:??"; + $markcolor = "white"; # Both unknown + } + elsif ($s_maxcsn && (!$c_maxcsn || $c_maxcsn eq "Unavailable")) { $lag_str = "- ?:??:??"; $markcolor = &get_color (36000); # assume consumer has big latency } - elsif (!$s_maxcsn && $c_maxcsn) { + elsif ((!$s_maxcsn || $s_maxcsn eq "Unavailable") && $c_maxcsn) { $lag_str = "+ ?:??:??"; $markcolor = &get_color (1); # consumer is ahead of supplier } @@ -1181,7 +1188,7 @@ sub to_decimal_csn { my ($maxcsn) = @_; if (!$maxcsn || $maxcsn eq "" || $maxcsn eq "Unavailable") { - return "none"; + return "Unavailable"; } my ($tm, $seq, $masterid, $subseq) = unpack("a8 a4 a4 a4", $maxcsn); @@ -1196,9 +1203,13 @@ sub to_decimal_csn sub to_string_csn { - my ($rawcsn, $decimalcsn) = split(/:/, "@_"); + my $str = shift; + if (!defined($str)){ + return "Unavailable"; + } + my ($rawcsn, $decimalcsn) = split(/:/, "$str"); if (!$rawcsn || $rawcsn eq "") { - return "none"; + return "Unavailable"; } if ($rawcsn eq "Unavailable"){ return $rawcsn; @@ -1222,7 +1233,7 @@ sub get_color $lag_minute /= 60; my ($color) = $allcolors { $colorkeys[0] }; - foreach ( keys %allcolors) { + foreach ( sort keys %allcolors) { if ($lag_minute >= $_){ $color = $allcolors {$_}; } @@ -1301,14 +1312,15 @@ sub print_legend if($opt_s){ return; } print "\n

Time Lag Legend:

\n"; print "\n\n"; + print "\n\n"; my ($i, $j); for ($i = 0; $i < $nlegends - 1; $i++) { $j = $colorkeys[$i]; - print "\n\n"; + print "\n\n"; } $j = $colorkeys[$i]; - print "\n\n"; - print "\n\n"; + print "\n\n"; + print "\n\n"; print "
Unknown
within $colorkeys[$i+1] min
Within $colorkeys[$i+1] minutes
over $colorkeys[$i] min
server n/a
Over $colorkeys[$i] minutes
Server n/a

\n"; } diff --git a/man/man1/repl-monitor.1 b/man/man1/repl-monitor.1 index 37a5fa4..17b9c4b 100644 --- a/man/man1/repl-monitor.1 +++ b/man/man1/repl-monitor.1 @@ -2,7 +2,7 @@ .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) -.TH REPL-MONITOR 1 "May 18, 2008" +.TH REPL-MONITOR 1 "Jun 28, 2016" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -68,6 +68,56 @@ Prompt for passwords Print plain text report .br +.SH CONFIGURATION FILE +This section describes the various directives that can be used in the configuration file. +.TP +.B [connection] +The connection details about a replica +.br + +host:port:binddn:bindpwd:cert_file +.br + +or, +.br + +host:port=shadowport:binddn:bindpwd:cert_file +.TP +.B [alias] +Define an alias for a server, this alias is used in the report in place of the +hostname/port + +.br +alias = host:port +.TP +.B [color] +Set a color based on the replicaton lag time lowmark (in minutes) +.br + +.R lowmark = color +.SH EXAMPLE +Example of a configuration file: + +[connection] +.br +localhost.localdomain:3891:cn=directory manager:password:* +.br +localhost2.localdomain:3892:cn=directory manager:password:* + +[alias] +.br +MY_SYSTEM1 = localhost.localdomain:3891 +.br +MY_SYSTEM2 = localhost2.localdomain:3892 + +[color] +.br +0 = #CCFFCC +.br +5 = #FFFFCC +.br +60 = #FFCCCC + .SH AUTHOR repl-monitor was written by the 389 Project. .SH "REPORTING BUGS" @@ -75,14 +125,14 @@ Report bugs to https://fedorahosted.org/389/newticket. .SH COPYRIGHT Copyright \(co 2001 Sun Microsystems, Inc. Used by permission. .br -Copyright \(co 2008 Red Hat, Inc. +Copyright \(co 2016 Red Hat, Inc. .br This manual page was written by Michele Baldessari , for the Debian project (but may be used by others). .br -Manual page updated by Mark Reynolds 10/11/13 +Manual page updated by Mark Reynolds 6/28/2016 .br This is free software. You may redistribute copies of it under the terms of the Directory Server license found in the LICENSE file of this software distribution. This license is essentially the GNU General Public -License version 2 with an exception for plug\(hyin distribution. +License version 3 with an exception for plug\(hyin distribution.