MediaWiki
REL1_22
|
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 public function execute() { 00038 global $wgAllDBsAreLocalhost; 00039 if ( $wgAllDBsAreLocalhost ) { 00040 $host = 'localhost'; 00041 } elseif ( $this->hasOption( 'group' ) ) { 00042 $db = wfGetDB( DB_SLAVE, $this->getOption( 'group' ) ); 00043 $host = $db->getServer(); 00044 } else { 00045 $lb = wfGetLB(); 00046 $i = $lb->getReaderIndex(); 00047 $host = $lb->getServerName( $i ); 00048 } 00049 $this->output( "$host\n" ); 00050 } 00051 } 00052 00053 $maintClass = "GetSlaveServer"; 00054 require_once RUN_MAINTENANCE_IF_MAIN;