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