class DatabaseLag extends Maintenance {
public function __construct() {
parent::__construct();
- $this->mDescription = "Shows database lag";
+ $this->addDescription( 'Shows database lag' );
$this->addOption( 'r', "Don't exit immediately, but show the lag every 5 seconds" );
}
if ( $this->hasOption( 'r' ) ) {
$lb = wfGetLB();
echo 'time ';
- for ( $i = 1; $i < $lb->getServerCount(); $i++ ) {
+
+ $serverCount = $lb->getServerCount();
+ for ( $i = 1; $i < $serverCount; $i++ ) {
$hostname = $lb->getServerName( $i );
printf( "%-12s ", $hostname );
}
echo "\n";
while ( 1 ) {
- $lb->clearLagTimeCache();
$lags = $lb->getLagTimes();
unset( $lags[0] );
echo gmdate( 'H:i:s' ) . ' ';