Fixes issues with complex background rules containing extra information after the...
[lhc/web/wiklou.git] / maintenance / lag.php
index d5c1985..e2191ac 100644 (file)
@@ -6,7 +6,7 @@
  * @ingroup Maintenance
  */
 
-require_once( dirname(__FILE__) . '/Maintenance.php' );
+require_once( dirname( __FILE__ ) . '/Maintenance.php' );
 
 class DatabaseLag extends Maintenance {
        public function __construct() {
@@ -18,27 +18,28 @@ class DatabaseLag extends Maintenance {
        public function execute() {
                if ( $this->hasOption( 'r' ) ) {
                        $lb = wfGetLB();
-                       $this->output( 'time     ' );
-                       for( $i = 0; $i < $lb->getServerCount(); $i++ ) {
+                       echo 'time     ';
+                       for ( $i = 1; $i < $lb->getServerCount(); $i++ ) {
                                $hostname = $lb->getServerName( $i );
-                               $this->output( sprintf( "%-12s ", $hostname ) );
+                               printf( "%-12s ", $hostname );
                        }
-                       $this->output( "\n" );
+                       echo "\n";
 
-                       while( 1 ) {
+                       while ( 1 ) {
+                               $lb->clearLagTimeCache();
                                $lags = $lb->getLagTimes();
                                unset( $lags[0] );
-                               $this->output( gmdate( 'H:i:s' ) . ' ' );
-                               foreach( $lags as $i => $lag ) {
-                                       $this->output( sprintf( "%-12s " , $lag === false ? 'false' : $lag ) );
+                               echo gmdate( 'H:i:s' ) . ' ';
+                               foreach ( $lags as $i => $lag ) {
+                                       printf( "%-12s " , $lag === false ? 'false' : $lag );
                                }
-                               $this->output( "\n" );
+                               echo "\n";
                                sleep( 5 );
                        }
                } else {
                        $lb = wfGetLB();
                        $lags = $lb->getLagTimes();
-                       foreach( $lags as $i => $lag ) {
+                       foreach ( $lags as $i => $lag ) {
                                $name = $lb->getServerName( $i );
                                $this->output( sprintf( "%-20s %s\n" , $name, $lag === false ? 'false' : $lag ) );
                        }