MediaWiki
REL1_24
|
00001 <?php 00024 require_once __DIR__ . '/Maintenance.php'; 00025 00031 class GetSlaveServer extends Maintenance { 00032 public function __construct() { 00033 parent::__construct(); 00034 $this->addOption( "group", "Query group to check specifically" ); 00035 $this->mDescription = "Report the hostname of a slave server"; 00036 } 00037 00038 public function execute() { 00039 global $wgAllDBsAreLocalhost; 00040 if ( $wgAllDBsAreLocalhost ) { 00041 $host = 'localhost'; 00042 } elseif ( $this->hasOption( 'group' ) ) { 00043 $db = wfGetDB( DB_SLAVE, $this->getOption( 'group' ) ); 00044 $host = $db->getServer(); 00045 } else { 00046 $lb = wfGetLB(); 00047 $i = $lb->getReaderIndex(); 00048 $host = $lb->getServerName( $i ); 00049 } 00050 $this->output( "$host\n" ); 00051 } 00052 } 00053 00054 $maintClass = "GetSlaveServer"; 00055 require_once RUN_MAINTENANCE_IF_MAIN;