本文整理汇总了PHP中DBConnection::getReplicateDelay方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnection::getReplicateDelay方法的具体用法?PHP DBConnection::getReplicateDelay怎么用?PHP DBConnection::getReplicateDelay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnection
的用法示例。
在下文中一共展示了DBConnection::getReplicateDelay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
// check_http -H servername -u /glpi/status.php -s GLPI_OK
// Plain text content
header('Content-type: text/plain');
$ok_master = true;
$ok_slave = true;
$ok = true;
// Check slave server connection
if (DBConnection::isDBSlaveActive()) {
$DBslave = DBConnection::getDBSlaveConf();
if (is_array($DBslave->dbhost)) {
$hosts = $DBslave->dbhost;
} else {
$hosts = array($DBslave->dbhost);
}
foreach ($hosts as $num => $name) {
$diff = DBConnection::getReplicateDelay($num);
if (abs($diff) > 1000000000) {
echo "GLPI_DBSLAVE_{$num}_OFFLINE\n";
$ok_slave = false;
} else {
if (abs($diff) > HOUR_TIMESTAMP) {
echo "GLPI_DBSLAVE_{$num}_PROBLEM\n";
$ok_slave = false;
} else {
echo "GLPI_DBSLAVE_{$num}_OK\n";
}
}
}
} else {
echo "No slave DB\n";
}
示例2: methodStatus
/**
* This method return GLPI status (same as status.php)
*
* @param $params array of option : ignored
* @param $protocol the communication protocol used
*
* @return an response ready to be encode
**/
static function methodStatus($params, $protocol)
{
global $DB;
if (isset($params['help'])) {
return array('help' => 'bool,optional');
}
$resp = array();
$ok_master = true;
$ok_slave = true;
$ok = true;
// Check slave server connection
if (DBConnection::isDBSlaveActive()) {
$DBslave = DBConnection::getDBSlaveConf();
if (is_array($DBslave->dbhost)) {
$hosts = $DBslave->dbhost;
} else {
$hosts = array($DBslave->dbhost);
}
foreach ($hosts as $num => $name) {
$diff = DBConnection::getReplicateDelay($num);
if ($diff > 1000000000) {
$resp['slavedb_' . $num] = "offline";
$ok_slave = false;
} else {
if ($diff) {
$resp['slavedb_' . $num] = $diff;
if ($diff > HOUR_TIMESTAMP) {
$ok_slave = false;
}
} else {
$resp['slavedb_' . $num] = "ok";
}
}
}
} else {
$resp['slavedb'] = "not configured";
}
// Check main server connection
if (DBConnection::establishDBConnection(false, true, false)) {
$resp['maindb'] = "ok";
} else {
$resp['slavedb'] = "offline";
$ok_master = false;
}
// Slave and master ok;
$ok = $ok_slave && $ok_master;
// Check session dir (usefull when NFS mounted))
if (is_dir(GLPI_SESSION_DIR) && is_writable(GLPI_SESSION_DIR)) {
$resp['sessiondir'] = "ok";
} else {
$resp['sessiondir'] = "not writable";
$ok = false;
}
// Reestablished DB connection
if (($ok_master || $ok_slave) && DBConnection::establishDBConnection(false, false, false)) {
// Check Auth connections
$auth = new Auth();
$auth->getAuthMethods();
$ldap_methods = $auth->authtypes["ldap"];
if (count($ldap_methods)) {
foreach ($ldap_methods as $method) {
if ($method['is_active']) {
if (AuthLdap::tryToConnectToServer($method, $method["rootdn"], Toolbox::decrypt($method["rootdn_passwd"], GLPIKEY))) {
$resp['LDAP_' . $method['name']] = "ok";
} else {
$resp['LDAP_' . $method['name']] = "offline";
$ok = false;
}
}
}
}
}
if ($ok) {
$resp['glpi'] = "ok";
} else {
$resp['glpi'] = "error";
}
return $resp;
}