Exemplo n.º 1
0
 /**
  * MYSQL_ADD_SLAVE, MYSQL_CHANGE_MASTER, MYSQL_DEL_SLAVE actions modifier/
  * @param string $actionId - action idenifyer
  * @param array $actionParams - action parameters
  * @param string $hostname - server hostname
  * @return array - modifyed action params
  * @throws NeedMoreUserInfoException
  */
 public static function checkExtraDbExist($actionId, $actionParams, $hostname)
 {
     if ($actionId == "MYSQL_ADD_SLAVE" || $actionId == "MYSQL_CHANGE_MASTER") {
         $hostname = ServersData::getDbMasterHostname();
     }
     if (Helper::isExtraDbExist($hostname)) {
         $actionParams["CHECK_EXTRA_DB_USER_ASK"] = "Y";
         throw new NeedMoreUserInfoException("Need more user's info", $actionParams);
     }
     return $actionParams;
 }
Exemplo n.º 2
0
 protected function getServerParams()
 {
     return ServersData::getServer($this->serverHostname);
 }
Exemplo n.º 3
0
$APPLICATION->SetAdditionalCSS("/bitrix/js/scale/css/scale-page-style.css");
$APPLICATION->AddHeadScript("/bitrix/js/scale/core.js");
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
if (\Bitrix\Scale\Helper::checkBxEnvVersion()) {
    if (\Bitrix\Scale\Monitoring::isEnabled()) {
        $serversList = \Bitrix\Scale\ServersData::getList();
        reset($serversList);
        $serverHostname = isset($_REQUEST["SERVER_HOSTNAME"]) ? htmlspecialcharsbx($_REQUEST["SERVER_HOSTNAME"]) : key($serversList);
        $monitoringCategoryId = isset($_REQUEST["GRAPH_CATEGORY"]) ? htmlspecialcharsbx($_REQUEST["GRAPH_CATEGORY"]) : "SYSTEM";
        $period = isset($_REQUEST["PERIOD"]) ? htmlspecialcharsbx($_REQUEST["PERIOD"]) : "day";
        $graphCategories = array();
        $sFilterID = "scale_graph_filter_id";
        $oFilter = new CAdminFilter($sFilterID, array(Loc::getMessage("SCALE_GRAPH_SELECT_SERVER"), Loc::getMessage("SCALE_GRAPH_SELECT_CATEGORY"), Loc::getMessage("SCALE_GRAPH_SELECT_PERIOD")));
        $graphs = \Bitrix\Scale\GraphData::getList();
        foreach ($serversList as $hostname => $server) {
            $graphCategories[$hostname] = \Bitrix\Scale\ServersData::getGraphCategories($hostname);
            foreach ($graphCategories[$hostname] as $key => $category) {
                if (!isset($graphs[$category])) {
                    continue;
                }
                $graphCategories[$hostname][$category] = isset($graphs[$category]["NAME"]) ? $graphs[$category]["NAME"] : $category;
                unset($graphCategories[$hostname][$key]);
            }
        }
        ?>
		<form name="form1" method="GET" action="<?php 
        echo $APPLICATION->GetCurPage();
        ?>
?">
			<?php 
        $oFilter->Begin();
Exemplo n.º 4
0
$APPLICATION->AddHeadScript("/bitrix/js/scale/core.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/communicator.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/collection.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/actionsparamstypes.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/actionprocessdialog.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/actionparamsdialog.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/actionresultdialog.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/loadbar.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/role.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/action.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/infotable.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/itloadbar.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/server.js");
$APPLICATION->AddHeadScript("/bitrix/js/scale/admin_frame.js");
$APPLICATION->SetAdditionalCSS("/bitrix/js/scale/css/scale-page-style.css");
$serversList = \Bitrix\Scale\ServersData::getList();
$jsLangMesIds = array("SCALE_PANEL_JS_APD_BUT_START", "SCALE_PANEL_JS_APD_2_CONFIRM", "SCALE_PANEL_JS_APD_2_NOT_CONCIDE", "SCALE_PANEL_JS_ACT_CONFIRM", "SCALE_PANEL_JS_ERROR", "SCALE_PANEL_JS_ARD_RES", "SCALE_PANEL_JS_ACT_RES_ERROR", "SCALE_PANEL_JS_ARD_NAME", "SCALE_PANEL_JS_ARD_RESULT", "SCALE_PANEL_JS_ARD_MESSAGE", "SCALE_PANEL_JS_APD_TITLE", "SCALE_PANEL_JS_ACT_EXEC_ERROR", "SCALE_PANEL_JS_ACT_EXEC_SUCCESS", "SCALE_PANEL_JS_MENU", "SCALE_PANEL_JS_PASS_MUST_BE_CHANGED", "SCALE_PANEL_JS_BID_ERROR", "SCALE_JS_SERVER_TITLE_TITLE", "SCALE_PANEL_MONITORING_DISABLED", "SCALE_PANEL_JS_ADVICE_TO_BACKUP", "SCALE_PANEL_JS_GLOBAL_ACTIONS", "SCALE_PANEL_JS_MONITORING_DATABASE_CREATING", "SCALE_PANEL_JS_ACT_CONFIRM_TITLE", "SCALE_PANEL_JS_ADVICE_TO_BACKUP_TITLE", "SCALE_PANEL_JS_CANCEL", "SCALE_PANEL_JS_CLOSE", "SCALE_PANEL_JS_BX_ENV_NOT_INSTALLED", "SCALE_PANEL_JS_BX_ENV_NEED_UPDATE", "SCALE_PANEL_JS_BX_ENV_VERSION");
$dataRefreshTimeInterval = 300000;
//ms how often we want to refresh monitoring info.
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
if (\Bitrix\Scale\Helper::checkBxEnvVersion()) {
    ?>
	<div class="adm-scale-page-wrap" id="adm-scale-page-wrap">
		<div class="adm-scale-blocks-wrapper" id="adm-scale-blocks-wrapper"<?php 
    echo empty($serversList) ? ' style="width:100%;"' : '';
    ?>
>
			<?php 
    if (!empty($serversList)) {
        ?>
				<div class="adm-scale-block adm-scale-block-empty" onclick="BX.Scale.actionsCollection.getObject('NEW_SERVER_CHAIN').start('',{ HOSTNAME: BX.Scale.AdminFrame.getNewServerName()});">
Exemplo n.º 5
0
 public static function isExtraDbExist($hostname)
 {
     $dbList = ServersData::getDbList($hostname);
     $connection = \Bitrix\Main\Application::getConnection();
     $currentDb = $connection->getDbName();
     $dbCount = count($dbList);
     if ($dbCount > 1 || $dbCount == 1 && !in_array($currentDb, $dbList)) {
         $result = true;
     } else {
         $result = false;
     }
     return $result;
 }
Exemplo n.º 6
0
 /**
  * Starts the action execution
  * @param array $inputParams
  * @return int code returned by shell
  * @throws \Bitrix\Main\ArgumentTypeException
  */
 public function start($inputParams = array())
 {
     if (!is_array($inputParams)) {
         throw new \Bitrix\Main\ArgumentTypeException("inputParams", "array");
     }
     if (isset($this->actionParams["CHECK_EXTRA_DB"]) && $this->actionParams["CHECK_EXTRA_DB"] == "Y") {
         $dbList = ServersData::getDbList($this->serverHostname);
         $connection = \Bitrix\Main\Application::getConnection();
         $currentDb = $connection->getDbName();
         $dbCount = count($dbList);
         if ($dbCount > 1 || $dbCount == 1 && !in_array($currentDb, $dbList)) {
             $error = Loc::getMessage("SCALE_ACTION_EXTRA_DB_EXIST");
             $this->makeLogRecords("", false, "", $error);
             throw new \Exception(Loc::getMessage("SCALE_ACTION_EXTRA_DB_EXIST"));
         }
     }
     $result = null;
     $command = $this->makeStartCommand($inputParams);
     $result = $this->shellAdapter->syncExec($command);
     $output = $this->shellAdapter->getLastOutput();
     $arOutput = array();
     if (strlen($output) > 0) {
         $arOut = json_decode($output, true);
         if (is_array($arOut) && !empty($arOut)) {
             $arOutput = $arOut;
         }
     }
     $error = $this->shellAdapter->getLastError();
     $this->makeLogRecords($command, $result, $output, $error);
     $this->result = array($this->id => array("NAME" => isset($this->actionParams["NAME"]) ? $this->actionParams["NAME"] : "[" . $this->id . "]", "RESULT" => $result ? "OK" : "ERROR", "OUTPUT" => array("TEXT" => $output, "DATA" => $arOutput), "ERROR" => $error));
     return $result;
 }