7 require_once( "Maintenance.php" );
9 class GetLagTimes
extends Maintenance
{
10 public function __construct() {
11 parent
::__construct();
12 $this->mDescription
= "Dump replication lag times";
15 public function execute() {
18 if( $lb->getServerCount() == 1 ) {
19 $this->error( "This script dumps replication lag times, but you don't seem to have\n"
20 . "a multi-host db server configuration.\n" );
22 $lags = $lb->getLagTimes();
23 foreach( $lags as $n => $lag ) {
24 $host = $lb->getServerName( $n );
25 if( IP
::isValid( $host ) ) {
27 $host = gethostbyaddr( $host );
29 $ip = gethostbyname( $host );
31 $starLen = min( intval( $lag ), 40 );
32 $stars = str_repeat( '*', $starLen );
33 $this->output( sprintf( "%10s %20s %3d %s\n", $ip, $host, $lag, $stars ) );
39 $maintClass = "GetLagTimes";
40 require_once( DO_MAINTENANCE
);