00001 <?php 00007 require 'commandLine.inc'; 00008 00009 $lb = wfGetLB(); 00010 00011 if( $lb->getServerCount() == 1 ) { 00012 echo "This script dumps replication lag times, but you don't seem to have\n"; 00013 echo "a multi-host db server configuration.\n"; 00014 } else { 00015 $lags = $lb->getLagTimes(); 00016 foreach( $lags as $n => $lag ) { 00017 $host = $lb->getServerName( $n ); 00018 if( IP::isValid( $host ) ) { 00019 $ip = $host; 00020 $host = gethostbyaddr( $host ); 00021 } else { 00022 $ip = gethostbyname( $host ); 00023 } 00024 $starLen = min( intval( $lag ), 40 ); 00025 $stars = str_repeat( '*', $starLen ); 00026 printf( "%10s %20s %3d %s\n", $ip, $host, $lag, $stars ); 00027 } 00028 } 00029