MediaWiki
REL1_19
|
00001 <?php 00021 require_once( dirname( __FILE__ ) . '/Maintenance.php' ); 00022 00023 class GetLagTimes extends Maintenance { 00024 public function __construct() { 00025 parent::__construct(); 00026 $this->mDescription = "Dump replication lag times"; 00027 } 00028 00029 public function execute() { 00030 $lb = wfGetLB(); 00031 00032 if ( $lb->getServerCount() == 1 ) { 00033 $this->error( "This script dumps replication lag times, but you don't seem to have\n" 00034 . "a multi-host db server configuration." ); 00035 } else { 00036 $lags = $lb->getLagTimes(); 00037 foreach ( $lags as $n => $lag ) { 00038 $host = $lb->getServerName( $n ); 00039 if ( IP::isValid( $host ) ) { 00040 $ip = $host; 00041 $host = gethostbyaddr( $host ); 00042 } else { 00043 $ip = gethostbyname( $host ); 00044 } 00045 $starLen = min( intval( $lag ), 40 ); 00046 $stars = str_repeat( '*', $starLen ); 00047 $this->output( sprintf( "%10s %20s %3d %s\n", $ip, $host, $lag, $stars ) ); 00048 } 00049 } 00050 } 00051 } 00052 00053 $maintClass = "GetLagTimes"; 00054 require_once( RUN_MAINTENANCE_IF_MAIN );