• Модуль: perfmon
  • Путь к файлу: ~/bitrix/modules/perfmon/classes/general/measure.php
  • Класс: CPerfAccel
  • Вызов: CPerfAccel::GetRecommendations
function GetRecommendations()
{
	$arResult = [];
	$arParams = $this->GetParams();

	if (array_key_exists("enabled", $arParams))
	{
		$is_ok = $this->enabled;
		foreach ($arParams["enabled"] as $ar)
		{
			if (!isset($ar["IS_OK"]))
			{
				$ar["IS_OK"] = $is_ok;
			}
			$arResult[] = $ar;
		}
	}

	if (array_key_exists("cache_ttl", $arParams))
	{
		$is_ok = $this->cache_ttl != 0;
		foreach ($arParams["cache_ttl"] as $ar)
		{
			if (!isset($ar["IS_OK"]))
			{
				$ar["IS_OK"] = $is_ok;
			}
			$arResult[] = $ar;
		}
	}

	if (array_key_exists("max_file_size", $arParams) && $this->max_file_size >= 0)
	{
		$is_ok = $this->max_file_size >= 4 * 1024 * 1024;
		foreach ($arParams["max_file_size"] as $ar)
		{
			if (!isset($ar["IS_OK"]))
			{
				$ar["IS_OK"] = $is_ok;
			}
			$arResult[] = $ar;
		}
	}

	if (array_key_exists("check_mtime", $arParams))
	{
		$is_ok = $this->check_mtime;
		foreach ($arParams["check_mtime"] as $ar)
		{
			if (!isset($ar["IS_OK"]))
			{
				$ar["IS_OK"] = $is_ok;
			}
			$arResult[] = $ar;
		}
	}

	if (array_key_exists("memory_pct", $arParams) && $this->memory_used >= 0)
	{
		if ($this->memory_total > 0)
		{
			//Check for 10% free
			$is_ok = ($this->memory_used / $this->memory_total) <= 0.9;
			foreach ($arParams["memory_pct"] as $ar)
			{
				$arResult[] = [
					"PARAMETER" => $ar["PARAMETER"],
					"VALUE" => Loc::getMessage(
						"PERFMON_MEASURE_MEMORY_USAGE",
						["#percent#" => number_format(($this->memory_used / $this->memory_total) * 100, 2)]
					),
					"RECOMMENDATION" => Loc::getMessage("PERFMON_MEASURE_CACHE_REC"),
					"IS_OK" => $is_ok,
				];
			}
		}
		else
		{
			foreach ($arParams["memory_pct"] as $ar)
			{
				$arResult[] = [
					"PARAMETER" => $ar["PARAMETER"],
					"VALUE" => "",
					"RECOMMENDATION" => Loc::getMessage("PERFMON_MEASURE_GREATER_THAN_ZERO_REC"),
					"IS_OK" => false,
				];
			}
		}
	}
	elseif (array_key_exists("memory_abs", $arParams))
	{
		//Or at least 40M total when no used memory stat available
		$is_ok = $this->memory_total >= 40 * 1024 * 1024;
		foreach ($arParams["memory_abs"] as $ar)
		{
			if (!isset($ar["IS_OK"]))
			{
				$ar["IS_OK"] = $is_ok;
			}
			$arResult[] = $ar;
		}
	}

	if (array_key_exists("cache_limit", $arParams))
	{
		$is_ok = $this->cache_limit != 0;
		foreach ($arParams["cache_limit"] as $ar)
		{
			if (!isset($ar["IS_OK"]))
			{
				$ar["IS_OK"] = $is_ok;
			}
			$arResult[] = $ar;
		}
	}

	return $arResult;
}