Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php |
— | — | @@ -57,6 +57,9 @@ |
58 | 58 | $filteriw = isset($params['filteriw']) ? $params['filteriw'] : false; |
59 | 59 | $this->appendInterwikiMap($p, $filteriw); |
60 | 60 | break; |
| 61 | + case 'dbserverlag' : |
| 62 | + $this->appendDbServerLagInfo($p, $params['showalldb']); |
| 63 | + break; |
61 | 64 | } |
62 | 65 | } |
63 | 66 | } |
— | — | @@ -127,7 +130,32 @@ |
128 | 131 | $this->getResult()->setIndexedTagName($data, 'iw'); |
129 | 132 | $this->getResult()->addValue('query', $property, $data); |
130 | 133 | } |
| 134 | + |
| 135 | + protected function appendDbServerLagInfo($property, $includeAll) { |
| 136 | + global $wgLoadBalancer; |
131 | 137 | |
| 138 | + $data = array(); |
| 139 | + |
| 140 | + if ($includeAll) { |
| 141 | + global $wgDBservers; |
| 142 | + $lags = $wgLoadBalancer->getLagTimes(); |
| 143 | + foreach( $lags as $i => $lag ) { |
| 144 | + $data[] = array ( |
| 145 | + 'host' => $wgDBservers[$i]['host'], |
| 146 | + 'lag' => $lag); |
| 147 | + } |
| 148 | + } else { |
| 149 | + list( $host, $lag ) = $wgLoadBalancer->getMaxLag(); |
| 150 | + $data[] = array ( |
| 151 | + 'host' => $host, |
| 152 | + 'lag' => $lag); |
| 153 | + } |
| 154 | + |
| 155 | + $result = $this->getResult(); |
| 156 | + $result->setIndexedTagName($data, 'db'); |
| 157 | + $result->addValue('query', $property, $data); |
| 158 | + } |
| 159 | + |
132 | 160 | protected function getAllowedParams() { |
133 | 161 | return array ( |
134 | 162 | |
— | — | @@ -137,7 +165,8 @@ |
138 | 166 | ApiBase :: PARAM_TYPE => array ( |
139 | 167 | 'general', |
140 | 168 | 'namespaces', |
141 | | - 'interwikimap' |
| 169 | + 'interwikimap', |
| 170 | + 'dbserverlag', |
142 | 171 | )), |
143 | 172 | |
144 | 173 | 'filteriw' => array ( |
— | — | @@ -145,6 +174,8 @@ |
146 | 175 | 'local', |
147 | 176 | '!local', |
148 | 177 | )), |
| 178 | + |
| 179 | + 'showalldb' => false, |
149 | 180 | ); |
150 | 181 | } |
151 | 182 | |
— | — | @@ -154,9 +185,11 @@ |
155 | 186 | 'Which sysinfo properties to get:', |
156 | 187 | ' "general" - Overall system information', |
157 | 188 | ' "namespaces" - List of registered namespaces (localized)', |
158 | | - ' "interwikimap" - Return interwiki map (optionally filtered)' |
| 189 | + ' "interwikimap" - Return interwiki map (optionally filtered)', |
| 190 | + ' "dbserverlag" - Get highest database replication server lag', |
159 | 191 | ), |
160 | 192 | 'filteriw' => 'Return only local or only nonlocal entries of the interwiki map', |
| 193 | + 'showalldb' => 'List all DB servers, not just the one lagging the most', |
161 | 194 | ); |
162 | 195 | } |
163 | 196 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -305,6 +305,7 @@ |
306 | 306 | * backlinks, embeddedin and imageusage lists should use (bl|ei|iu)title parameter |
307 | 307 | instead of titles. Titles for these lists is obsolete and might stop working soon. |
308 | 308 | * Added prop=imageinfo - gets image properties and upload history |
| 309 | +* (bug 10211) Added db server replication lag information in meta=siteinfo |
309 | 310 | |
310 | 311 | == Maintenance script changes since 1.10 == |
311 | 312 | |