Revert r52336 "Merge maintenance-work branch:"
[lhc/web/wiklou.git] / maintenance / getLagTimes.php
1 <?php
2 /**
3 * @file
4 * @ingroup Maintenance
5 */
6
7 require 'commandLine.inc';
8
9 $lb = wfGetLB();
10
11 if( $lb->getServerCount() == 1 ) {
12 echo "This script dumps replication lag times, but you don't seem to have\n";
13 echo "a multi-host db server configuration.\n";
14 } else {
15 $lags = $lb->getLagTimes();
16 foreach( $lags as $n => $lag ) {
17 $host = $lb->getServerName( $n );
18 if( IP::isValid( $host ) ) {
19 $ip = $host;
20 $host = gethostbyaddr( $host );
21 } else {
22 $ip = gethostbyname( $host );
23 }
24 $starLen = min( intval( $lag ), 40 );
25 $stars = str_repeat( '*', $starLen );
26 printf( "%10s %20s %3d %s\n", $ip, $host, $lag, $stars );
27 }
28 }
29