コード例 #1
0
    function MySQLReplicationStatus($host,$clusters) {

        $db = new DBx ($clusters[$host]['ip'],$clusters[$host]['user'],$clusters[$host]['password']);

        if (!$db->query($this->slave_status_query)) {
            printf ("<p><font color=red>Error from MySQL server %s: %s (%s) for query: %s</font>",$clusters[$host]['ip'],$db->Error,$db->Errno,$this->slave_status_query);
            return false;
        }

		$db->next_record();

        $this->slave_master         = $db->f('Master_Host');
        $this->slave_user           = $db->f('Master_User');
        $this->slave_master_port    = $db->f('Master_Port');
        $this->slave_log_file	    = $db->f('Master_Log_File');
        $this->slave_position       = $db->f('Read_Master_Log_Pos');
        $this->slave_sql_running	= $db->f('Slave_SQL_Running');
        $this->slave_io_running	    = $db->f('Slave_IO_Running');
        $this->slave_last_errno	    = $db->f('Last_Errno');
        $this->slave_last_error 	= $db->f('Last_Error');
        $this->slave_seconds_behind = $db->f('Seconds_Behind_Master');

        if (!$db->query($this->master_status_query)) {
            printf ("<p><font color=red>MySQL error: %s (%s) for query: %s</font>",$db->Error,$db->Errno,$this->slave_status_query);
            return;
        }

		$db->next_record();

    	$this->master_position	    = $db->f('Position');
    	$this->master_log_file	    = $db->f('File');
        $this->slave_of     	    = $clusters[$host]['slave_of'];
        $this->color         	    = $clusters[$host]['color'];
    }