3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @ingroup Maintenance
21 require_once( "Maintenance.php" );
23 class GetLagTimes
extends Maintenance
{
24 public function __construct() {
25 parent
::__construct();
26 $this->mDescription
= "Dump replication lag times";
29 public function execute() {
32 if( $lb->getServerCount() == 1 ) {
33 $this->error( "This script dumps replication lag times, but you don't seem to have\n"
34 . "a multi-host db server configuration.\n" );
36 $lags = $lb->getLagTimes();
37 foreach( $lags as $n => $lag ) {
38 $host = $lb->getServerName( $n );
39 if( IP
::isValid( $host ) ) {
41 $host = gethostbyaddr( $host );
43 $ip = gethostbyname( $host );
45 $starLen = min( intval( $lag ), 40 );
46 $stars = str_repeat( '*', $starLen );
47 $this->output( sprintf( "%10s %20s %3d %s\n", $ip, $host, $lag, $stars ) );
53 $maintClass = "GetLagTimes";
54 require_once( DO_MAINTENANCE
);