* kw (new), el
[mediawiki.git] / maintenance / getLagTimes.php
blobd39345925a8b367fdbc68c2333533487a5ba1e05
1 <?php
3 require 'commandLine.inc';
5 if( empty( $wgDBservers ) ) {
6 echo "This script dumps replication lag times, but you don't seem to have\n";
7 echo "a multi-host db server configuration.\n";
8 } else {
9 $lags = $wgLoadBalancer->getLagTimes();
10 foreach( $lags as $n => $lag ) {
11 $host = $wgDBservers[$n]["host"];
12 if( IP::isValid( $host ) ) {
13 $ip = $host;
14 $host = gethostbyaddr( $host );
15 } else {
16 $ip = gethostbyname( $host );
18 $starLen = min( intval( $lag ), 40 );
19 $stars = str_repeat( '*', $starLen );
20 printf( "%10s %20s %3d %s\n", $ip, $host, $lag, $stars );