X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FgetLagTimes.php;h=72b1d48a2dd663806f69ec75cf6dbf171713f371;hb=e34865144f3f21bb8b0ad4ba76d3d10490a73462;hp=a3268eec11d1ba4c5f64b6c7335307eec5a7aa42;hpb=fbfb509df557ca9eef812f6645459c483149f186;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/getLagTimes.php b/maintenance/getLagTimes.php index a3268eec11..72b1d48a2d 100644 --- a/maintenance/getLagTimes.php +++ b/maintenance/getLagTimes.php @@ -1,25 +1,62 @@ mDescription = "Dump replication lag times"; + } + + public function execute() { + $lb = wfGetLB(); -if( $lb->getServerCount() == 1 ) { - echo "This script dumps replication lag times, but you don't seem to have\n"; - echo "a multi-host db server configuration.\n"; -} else { - $lags = $lb->getLagTimes(); - foreach( $lags as $n => $lag ) { - $host = $lb->getServerName( $n ); - if( IP::isValid( $host ) ) { - $ip = $host; - $host = gethostbyaddr( $host ); + 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 ) ); + } } - $starLen = min( intval( $lag ), 40 ); - $stars = str_repeat( '*', $starLen ); - printf( "%10s %20s %3d %s\n", $ip, $host, $lag, $stars ); } } +$maintClass = "GetLagTimes"; +require_once( RUN_MAINTENANCE_IF_MAIN );