X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FgetLagTimes.php;h=7365a2ee71d3d471443317de37bf7d9c084cdfe4;hb=df753940b9964b2239cdb421864b806f7b45b34d;hp=f2c06f6a7a9f3117287c99078ccccd18a091e650;hpb=9bbd3da81ee2c9bbef6015c88d094f88cf30422e;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/getLagTimes.php b/maintenance/getLagTimes.php index f2c06f6a7a..7365a2ee71 100644 --- a/maintenance/getLagTimes.php +++ b/maintenance/getLagTimes.php @@ -1,23 +1,62 @@ getLagTimes(); - foreach( $lags as $n => $lag ) { - $host = $wgDBservers[$n]["host"]; - if( IP::isValid( $host ) ) { - $ip = $host; - $host = gethostbyaddr( $host ); +/** + * Maintenance script that displays replication lag times. + * + * @ingroup Maintenance + */ +class GetLagTimes extends Maintenance { + public function __construct() { + parent::__construct(); + $this->mDescription = "Dump replication lag times"; + } + + public function execute() { + $lb = wfGetLB(); + + if ( $lb->getServerCount() == 1 ) { + $this->error( "This script dumps replication lag times, but you don't seem to have\n" + . "a multi-host db server configuration." ); } else { - $ip = gethostbyname( $host ); + $lags = $lb->getLagTimes(); + foreach ( $lags as $n => $lag ) { + $host = $lb->getServerName( $n ); + if ( IP::isValid( $host ) ) { + $ip = $host; + $host = gethostbyaddr( $host ); + } else { + $ip = gethostbyname( $host ); + } + $starLen = min( intval( $lag ), 40 ); + $stars = str_repeat( '*', $starLen ); + $this->output( sprintf( "%10s %20s %3d %s\n", $ip, $host, $lag, $stars ) ); + } } - $stars = str_repeat( '*', intval( $lag ) ); - printf( "%10s %20s %3d %s\n", $ip, $host, $lag, $stars ); } } -?> \ No newline at end of file +$maintClass = "GetLagTimes"; +require_once RUN_MAINTENANCE_IF_MAIN;