/**
  * Constructor
  */
 public function __construct()
 {
     if (extension_loaded('Zend OPcache')) {
         $this->_opCacheStats = opcache_get_status();
         $this->_opCacheConfig = opcache_get_configuration();
     }
 }
 /**
  * {@inheritDoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     // This is needed to support the PHP 5.5 opcache as well as the old ZendOptimizer+-extension.
     if (function_exists('opcache_get_status')) {
         $status = opcache_get_status();
         $config = opcache_get_configuration();
         $version = $config['version']['opcache_product_name'] . ' ' . $config['version']['version'];
         $stats = $status['opcache_statistics'];
         $hitrate = $stats['opcache_hit_rate'];
     } elseif (function_exists('accelerator_get_status')) {
         $status = accelerator_get_status();
         $config = accelerator_get_configuration();
         $version = $config['version']['accelerator_product_name'] . ' ' . $config['version']['version'];
         $stats = $status['accelerator_statistics'];
         $hitrate = $stats['accelerator_hit_rate'];
     }
     $filelist = array();
     if ($this->showFilelist) {
         foreach ($status['scripts'] as $key => $data) {
             $filelist[$key] = $data;
             $filelist[$key]['name'] = basename($key);
         }
     }
     // unset unneeded filelist to lower memory-usage
     unset($status['scripts']);
     $this->data = array('version' => $version, 'ini' => $config['directives'], 'filelist' => $filelist, 'status' => $status, 'stats' => $stats, 'hitrate' => $hitrate);
 }
Esempio n. 3
0
 public function shutdown($context, &$storage)
 {
     if ($this->shutdownCalled) {
         return;
     }
     $this->shutdownCalled = true;
     $status = opcache_get_status();
     $config = opcache_get_configuration();
     $storage['opMemoryUsage'][] = $status['memory_usage'];
     $storage['opInternedStringsUsage'][] = $status['interned_strings_usage'];
     $storage['opStatistics'][] = $status['opcache_statistics'];
     $storage['opDirectives'][] = $config['directives'];
     $storage['opVersion'][] = $config['version'];
     $storage['opBlacklist'][] = $config['blacklist'];
     $scripts = $status['scripts'];
     array_walk($scripts, function (&$item, $key) {
         $item = array_merge(array('name' => basename($item['full_path'])), array('Full Path' => $item['full_path']), $item);
         $item['memory Consumption'] = round($item['memory_consumption'] / 1024) . " KB ({$item['memory_consumption']} B)";
         $item['Last Used'] = $item['last_used'];
         $item['Last Used Timestamp'] = $item['last_used_timestamp'];
         $item['created'] = date("D M j G:i:s Y", $item['timestamp']);
         $item['created Timestamp'] = $item['timestamp'];
         unset($item['full_path']);
         unset($item['memory_consumption']);
         unset($item['last_used']);
         unset($item['last_used_timestamp']);
         unset($item['timestamp']);
     });
     $storage['opcacheScripts'] = $scripts;
 }
Esempio n. 4
0
 /**
  * Get OpCache configuration
  * @param void
  * @access public
  * @return array
  */
 public function configuration()
 {
     $config = null;
     if (function_exists('opcache_get_configuration')) {
         $config = opcache_get_configuration();
     }
     return $config;
 }
Esempio n. 5
0
 public function __construct(Config $config)
 {
     if (function_exists('opcache_get_configuration')) {
         $opcacheSettings = opcache_get_configuration();
         if ($opcacheSettings['directives']['opcache.enable'] !== false) {
             throw new \RuntimeException('ArraySeriesCache doesn\'t work with OPCache enabled.');
         }
     }
     $this->config = $config;
 }
Esempio n. 6
0
 public function __construct()
 {
     if (!extension_loaded('Zend OPcache')) {
         $this->_opcacheEnabled = false;
     } else {
         $this->_opcacheEnabled = true;
     }
     if ($this->_opcacheEnabled) {
         $this->_configuration = opcache_get_configuration();
         $this->_status = opcache_get_status();
     }
 }
Esempio n. 7
0
 /**
  * @return common_configuration_Report
  */
 public function check()
 {
     $error = null;
     if (!function_exists('opcache_get_configuration')) {
         $error = 'You can install OPcache extension to improve performance';
     } else {
         $configuration = opcache_get_configuration();
         if (!$configuration['directives']['opcache.enable']) {
             $error = 'You can enable OPcache extension to improve performance';
         }
     }
     $report = new common_configuration_Report(null !== $error ? common_configuration_Report::INVALID : common_configuration_Report::VALID, null !== $error ? $error : 'OPcache is installed', $this);
     return $report;
 }
 /**
  * Init JaguarEngine
  * @param 	Integer $mode 	The engine mode
  * @access 	Public
  * @return 	Boolean
  */
 public static function init(int $mode = 0) : bool
 {
     // Remove headers
     header_remove('X-Powered-By');
     header_remove('Server');
     /**
      * Mode Setup
      */
     self::$mode = $mode;
     // Development Setup
     if (self::$mode === self::MODE_DEVELOPMENT) {
         // Enable the error reporting
         error_reporting(-1);
         ini_set('display_errors', 'on');
         // Disable the OPCACHE plugin
         $opVars = opcache_get_configuration();
         if ($opVars['directives']['opcache.enable'] == true) {
             opcache_reset();
         }
     }
     // Production Setup
     if (self::$mode === self::MODE_PRODUCTION) {
         // Disable error reporting
         error_reporting(0);
         ini_set('display_errors', 'off');
     }
     // Initialisation
     self::setDefines();
     self::addFiles();
     self::setupEventSystem();
     // Setup error handling
     set_exception_handler(array('JEError', 'handleException'));
     set_error_handler(array('JEError', 'handleError'));
     register_shutdown_function(array('JEError', 'handleFatal'));
     // Register tests
     if (self::getFlag(self::FLAG_USE_VALIDATOR)) {
         JEValidate::register('email', new JETestEmail());
         JEValidate::register('id', new JETestID());
     }
     return true;
 }
Esempio n. 9
0
/**
 * Get a list of versions that are currently installed on the server.
 *
 * @package Admin
 * @param string[] $checkFor
 */
function getServerVersions($checkFor)
{
    global $txt, $memcached, $modSettings;
    $db = database();
    loadLanguage('Admin');
    $versions = array();
    // Is GD available?  If it is, we should show version information for it too.
    if (in_array('gd', $checkFor) && function_exists('gd_info')) {
        $temp = gd_info();
        $versions['gd'] = array('title' => $txt['support_versions_gd'], 'version' => $temp['GD Version']);
    }
    // Why not have a look at ImageMagick? If it is, we should show version information for it too.
    if (in_array('imagick', $checkFor) && class_exists('Imagick')) {
        $temp = new Imagick();
        $temp2 = $temp->getVersion();
        $versions['imagick'] = array('title' => $txt['support_versions_imagick'], 'version' => $temp2['versionString']);
    }
    // Now lets check for the Database.
    if (in_array('db_server', $checkFor)) {
        $conn = $db->connection();
        if (empty($conn)) {
            trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE);
        } else {
            $versions['db_server'] = array('title' => sprintf($txt['support_versions_db'], $db->db_title()), 'version' => '');
            $versions['db_server']['version'] = $db->db_server_version();
        }
    }
    // If we're using memcache we need the server info.
    if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') {
        require_once SUBSDIR . '/Cache.subs.php';
        get_memcached_server();
    } else {
        if (($key = array_search('memcache', $checkFor)) !== false) {
            unset($checkFor[$key]);
        }
    }
    // Check to see if we have any accelerators installed...
    if (in_array('mmcache', $checkFor) && defined('MMCACHE_VERSION')) {
        $versions['mmcache'] = array('title' => 'Turck MMCache', 'version' => MMCACHE_VERSION);
    }
    if (in_array('eaccelerator', $checkFor) && defined('EACCELERATOR_VERSION')) {
        $versions['eaccelerator'] = array('title' => 'eAccelerator', 'version' => EACCELERATOR_VERSION);
    }
    if (in_array('zend', $checkFor) && function_exists('zend_shm_cache_store')) {
        $versions['zend'] = array('title' => 'Zend SHM Accelerator', 'version' => zend_version());
    }
    if (in_array('apc', $checkFor) && extension_loaded('apc')) {
        $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc'));
    }
    if (in_array('memcache', $checkFor) && function_exists('memcache_set')) {
        $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached));
    }
    if (in_array('xcache', $checkFor) && function_exists('xcache_set')) {
        $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION);
    }
    if (in_array('opcache', $checkFor) && extension_loaded('Zend OPcache')) {
        $opcache_config = @opcache_get_configuration();
        if (!empty($opcache_config['directives']['opcache.enable'])) {
            $versions['opcache'] = array('title' => $opcache_config['version']['opcache_product_name'], 'version' => $opcache_config['version']['version']);
        }
    }
    // PHP Version
    if (in_array('php', $checkFor)) {
        $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION . ' (' . php_sapi_name() . ')', 'more' => '?action=admin;area=serversettings;sa=phpinfo');
    }
    // Server info
    if (in_array('server', $checkFor)) {
        $req = request();
        $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $req->server_software());
        // Compute some system info, if we can
        $versions['server_name'] = array('title' => $txt['support_versions'], 'version' => php_uname());
        $loading = detectServerLoad();
        if ($loading !== false) {
            $versions['server_load'] = array('title' => $txt['load_balancing_settings'], 'version' => $loading);
        }
    }
    return $versions;
}
Esempio n. 10
0
 /**
  * @param array $Configuration
  */
 public function setConfiguration($Configuration)
 {
     if (function_exists('opcache_get_status')) {
         $this->Status = opcache_get_status();
     }
     if (function_exists('opcache_get_configuration')) {
         $this->Config = opcache_get_configuration();
     }
 }
Esempio n. 11
0
 public function getConfig()
 {
     return opcache_get_configuration();
 }
Esempio n. 12
0
    /**
     * Cache settings editing and submission.
     *
     * This method handles the display, allows to edit, and saves the result
     * for _cacheSettings form.
     */
    public function action_cacheSettings_display()
    {
        global $context, $scripturl, $txt, $cache_accelerator, $modSettings;
        // Initialize the form
        $this->_initCacheSettingsForm();
        // Some javascript to enable / disable certain settings if the option is not selected
        addInlineJavascript('
			var cache_type = document.getElementById(\'cache_accelerator\');

			createEventListener(cache_type);
			cache_type.addEventListener("change", toggleCache);
			toggleCache();', true);
        $context['settings_message'] = $txt['caching_information'];
        // Let them know if they may have problems
        if ($cache_accelerator === 'filebased' && !empty($modSettings['cache_enable']) && extension_loaded('Zend OPcache')) {
            // The opcache will cache the filebased user data files, updating them based on opcache.revalidate_freq
            // which can cause delays (or prevent) the invalidation of file cache files
            $opcache_config = @opcache_get_configuration();
            if (!empty($opcache_config['directives']['opcache.enable'])) {
                $context['settings_message'] = $txt['cache_conflict'];
            }
        }
        // Saving again?
        if (isset($_GET['save'])) {
            call_integration_hook('integrate_save_cache_settings');
            $this->_cacheSettingsForm->save();
            // we need to save the $cache_enable to $modSettings as well
            updatesettings(array('cache_enable' => (int) $_POST['cache_enable']));
            // exit so we reload our new settings on the page
            redirectexit('action=admin;area=serversettings;sa=cache;' . $context['session_var'] . '=' . $context['session_id']);
        }
        loadLanguage('Maintenance');
        createToken('admin-maint');
        Template_Layers::getInstance()->add('clean_cache_button');
        $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cache;save';
        $context['settings_title'] = $txt['caching_settings'];
        // Prepare the template.
        createToken('admin-ssc');
        // Prepare settings for display in the template.
        $this->_cacheSettingsForm->prepare_file();
    }
Esempio n. 13
0
 /**
  * Show settings of the module
  *
  * @global     object    $objTemplate
  * @global     array    $_ARRAYLANG
  */
 function showSettings()
 {
     global $objTemplate, $_ARRAYLANG;
     $this->objTpl->loadTemplateFile('settings.html');
     $this->objTpl->setVariable(array('TXT_CACHE_GENERAL' => $_ARRAYLANG['TXT_SETTINGS_MENU_CACHE'], 'TXT_CACHE_STATS' => $_ARRAYLANG['TXT_CACHE_STATS'], 'TXT_CACHE_CONTREXX_CACHING' => $_ARRAYLANG['TXT_CACHE_CONTREXX_CACHING'], 'TXT_CACHE_USERCACHE' => $_ARRAYLANG['TXT_CACHE_USERCACHE'], 'TXT_CACHE_OPCACHE' => $_ARRAYLANG['TXT_CACHE_OPCACHE'], 'TXT_CACHE_PROXYCACHE' => $_ARRAYLANG['TXT_CACHE_PROXYCACHE'], 'TXT_CACHE_EMPTY' => $_ARRAYLANG['TXT_CACHE_EMPTY'], 'TXT_CACHE_STATS' => $_ARRAYLANG['TXT_CACHE_STATS'], 'TXT_CACHE_APC' => $_ARRAYLANG['TXT_CACHE_APC'], 'TXT_CACHE_ZEND_OPCACHE' => $_ARRAYLANG['TXT_CACHE_ZEND_OPCACHE'], 'TXT_CACHE_XCACHE' => $_ARRAYLANG['TXT_CACHE_XCACHE'], 'TXT_CACHE_MEMCACHE' => $_ARRAYLANG['TXT_CACHE_MEMCACHE'], 'TXT_CACHE_MEMCACHED' => $_ARRAYLANG['TXT_CACHE_MEMCACHED'], 'TXT_CACHE_FILESYSTEM' => $_ARRAYLANG['TXT_CACHE_FILESYSTEM'], 'TXT_CACHE_APC_ACTIVE_INFO' => $_ARRAYLANG['TXT_CACHE_APC_ACTIVE_INFO'], 'TXT_CACHE_APC_CONFIG_INFO' => $_ARRAYLANG['TXT_CACHE_APC_CONFIG_INFO'], 'TXT_CACHE_ZEND_OPCACHE_ACTIVE_INFO' => $_ARRAYLANG['TXT_CACHE_ZEND_OPCACHE_ACTIVE_INFO'], 'TXT_CACHE_ZEND_OPCACHE_CONFIG_INFO' => $_ARRAYLANG['TXT_CACHE_ZEND_OPCACHE_CONFIG_INFO'], 'TXT_CACHE_XCACHE_ACTIVE_INFO' => $_ARRAYLANG['TXT_CACHE_XCACHE_ACTIVE_INFO'], 'TXT_CACHE_XCACHE_CONFIG_INFO' => $_ARRAYLANG['TXT_CACHE_XCACHE_CONFIG_INFO'], 'TXT_CACHE_MEMCACHE_ACTIVE_INFO' => $_ARRAYLANG['TXT_CACHE_MEMCACHE_ACTIVE_INFO'], 'TXT_CACHE_MEMCACHE_CONFIG_INFO' => $_ARRAYLANG['TXT_CACHE_MEMCACHE_CONFIG_INFO'], 'TXT_CACHE_MEMCACHED_ACTIVE_INFO' => $_ARRAYLANG['TXT_CACHE_MEMCACHED_ACTIVE_INFO'], 'TXT_CACHE_MEMCACHED_CONFIG_INFO' => $_ARRAYLANG['TXT_CACHE_MEMCACHED_CONFIG_INFO'], 'TXT_CACHE_ENGINE' => $_ARRAYLANG['TXT_CACHE_ENGINE'], 'TXT_CACHE_INSTALLATION_STATE' => $_ARRAYLANG['TXT_CACHE_INSTALLATION_STATE'], 'TXT_CACHE_ACTIVE_STATE' => $_ARRAYLANG['TXT_CACHE_ACTIVE_STATE'], 'TXT_CACHE_CONFIGURATION_STATE' => $_ARRAYLANG['TXT_CACHE_CONFIGURATION_STATE'], 'TXT_SETTINGS_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_SETTINGS_ON' => $_ARRAYLANG['TXT_ACTIVATED'], 'TXT_SETTINGS_OFF' => $_ARRAYLANG['TXT_DEACTIVATED'], 'TXT_SETTINGS_STATUS' => $_ARRAYLANG['TXT_CACHE_SETTINGS_STATUS'], 'TXT_SETTINGS_STATUS_HELP' => $_ARRAYLANG['TXT_CACHE_SETTINGS_STATUS_HELP'], 'TXT_SETTINGS_EXPIRATION' => $_ARRAYLANG['TXT_CACHE_SETTINGS_EXPIRATION'], 'TXT_SETTINGS_EXPIRATION_HELP' => $_ARRAYLANG['TXT_CACHE_SETTINGS_EXPIRATION_HELP'], 'TXT_EMPTY_BUTTON' => $_ARRAYLANG['TXT_CACHE_EMPTY'], 'TXT_EMPTY_DESC' => $_ARRAYLANG['TXT_CACHE_EMPTY_DESC'], 'TXT_EMPTY_DESC_APC' => $_ARRAYLANG['TXT_CACHE_EMPTY_DESC_FILES_AND_ENRIES'], 'TXT_EMPTY_DESC_ZEND_OP' => $_ARRAYLANG['TXT_CACHE_EMPTY_DESC_FILES'], 'TXT_EMPTY_DESC_MEMCACHE' => $_ARRAYLANG['TXT_CACHE_EMPTY_DESC_MEMCACHE'], 'TXT_EMPTY_DESC_XCACHE' => $_ARRAYLANG['TXT_CACHE_EMPTY_DESC_FILES_AND_ENRIES'], 'TXT_STATS_FILES' => $_ARRAYLANG['TXT_CACHE_STATS_FILES'], 'TXT_STATS_FOLDERSIZE' => $_ARRAYLANG['TXT_CACHE_STATS_FOLDERSIZE'], 'TXT_STATS_CHACHE_SITE_COUNT' => $_ARRAYLANG['TXT_STATS_CHACHE_SITE_COUNT'], 'TXT_STATS_CHACHE_ENTRIES_COUNT' => $_ARRAYLANG['TXT_STATS_CHACHE_ENTRIES_COUNT'], 'TXT_STATS_CACHE_SIZE' => $_ARRAYLANG['TXT_STATS_CACHE_SIZE'], 'TXT_DEACTIVATED' => $_ARRAYLANG['TXT_DEACTIVATED'], 'TXT_DISPLAY_CONFIGURATION' => $_ARRAYLANG['TXT_DISPLAY_CONFIGURATION'], 'TXT_HIDE_CONFIGURATION' => $_ARRAYLANG['TXT_HIDE_CONFIGURATION']));
     $this->objTpl->setVariable($_ARRAYLANG);
     if ($this->objSettings->isWritable()) {
         $this->objTpl->parse('cache_submit_button');
     } else {
         $this->objTpl->hideBlock('cache_submit_button');
         $objTemplate->SetVariable('CONTENT_STATUS_MESSAGE', implode("<br />\n", $this->objSettings->strErrMessage));
     }
     // parse op cache engines
     $this->parseOPCacheEngines();
     // parse user cache engines
     $this->parseUserCacheEngines();
     $this->parseMemcacheSettings();
     $this->parseMemcachedSettings();
     $this->parseReverseProxySettings();
     $this->parseSsiProcessorSettings();
     $intFoldersizePages = 0;
     $intFoldersizeEntries = 0;
     $intFilesPages = 0;
     $intFilesEntries = 0;
     $handleFolder = opendir($this->strCachePath);
     if ($handleFolder) {
         while ($strFile = readdir($handleFolder)) {
             if ($strFile != '.' && $strFile != '..') {
                 if (is_dir($this->strCachePath . '/' . $strFile)) {
                     $intFoldersizeEntries += filesize($this->strCachePath . $strFile);
                     ++$intFilesEntries;
                 } elseif ($strFile !== '.htaccess') {
                     $intFoldersizePages += filesize($this->strCachePath . $strFile);
                     ++$intFilesPages;
                 }
             }
         }
         $intFoldersizeEntries = filesize($this->strCachePath) - $intFoldersizePages - filesize($this->strCachePath . '.htaccess');
         closedir($handleFolder);
     }
     if ($this->isInstalled(self::CACHE_ENGINE_APC) && $this->isConfigured(self::CACHE_ENGINE_APC) && ($this->opCacheEngine == self::CACHE_ENGINE_APC || $this->userCacheEngine == self::CACHE_ENGINE_APC)) {
         $this->objTpl->touchBlock('apcCachingStats');
         $apcSmaInfo = \apc_sma_info();
         $apcCacheInfo = \apc_cache_info();
     } else {
         $this->objTpl->hideBlock('apcCachingStats');
     }
     if ($this->isInstalled(self::CACHE_ENGINE_ZEND_OPCACHE) && $this->isConfigured(self::CACHE_ENGINE_ZEND_OPCACHE) && $this->opCacheEngine == self::CACHE_ENGINE_ZEND_OPCACHE && $this->getOpCacheActive()) {
         $this->objTpl->touchBlock('zendOpCachingStats');
         $opCacheConfig = \opcache_get_configuration();
         $opCacheStatus = \opcache_get_status();
     } else {
         $this->objTpl->hideBlock('zendOpCachingStats');
     }
     if ($this->isInstalled(self::CACHE_ENGINE_MEMCACHE) && $this->isConfigured(self::CACHE_ENGINE_MEMCACHE) && $this->userCacheEngine == self::CACHE_ENGINE_MEMCACHE && $this->getUserCacheActive()) {
         $this->objTpl->touchBlock('memcacheCachingStats');
         $memcacheStats = $this->memcache->getStats();
     } else {
         $this->objTpl->hideBlock('memcacheCachingStats');
     }
     if ($this->isInstalled(self::CACHE_ENGINE_MEMCACHED) && $this->isConfigured(self::CACHE_ENGINE_MEMCACHED) && $this->userCacheEngine == self::CACHE_ENGINE_MEMCACHED && $this->getUserCacheActive()) {
         $this->objTpl->touchBlock('memcachedCachingStats');
         $memcachedStats = $this->memcached->getStats();
     } else {
         $this->objTpl->hideBlock('memcachedCachingStats');
     }
     if ($this->isInstalled(self::CACHE_ENGINE_XCACHE) && $this->isConfigured(self::CACHE_ENGINE_XCACHE) && ($this->opCacheEngine == self::CACHE_ENGINE_XCACHE || $this->userCacheEngine == self::CACHE_ENGINE_XCACHE)) {
         $this->objTpl->touchBlock('xCacheCachingStats');
     } else {
         $this->objTpl->hideBlock('xCacheCachingStats');
     }
     if ($this->userCacheEngine == self::CACHE_ENGINE_FILESYSTEM && $this->getUserCacheActive()) {
         $this->objTpl->touchBlock('FileSystemCachingStats');
     } else {
         $this->objTpl->hideBlock('FileSystemCachingStats');
     }
     $apcSizeCount = isset($apcCacheInfo['nhits']) ? $apcCacheInfo['nhits'] : 0;
     $apcEntriesCount = 0;
     if (isset($apcCacheInfo)) {
         foreach ($apcCacheInfo['cache_list'] as $entity) {
             if (false !== strpos($entity['key'], $this->getCachePrefix())) {
                 $apcEntriesCount++;
             }
         }
     }
     $apcMaxSizeKb = isset($apcSmaInfo['num_seg']) && isset($apcSmaInfo['seg_size']) ? $apcSmaInfo['num_seg'] * $apcSmaInfo['seg_size'] / 1024 : 0;
     $apcSizeKb = isset($apcCacheInfo['mem_size']) ? $apcCacheInfo['mem_size'] / 1024 : 0;
     $opcacheSizeCount = !isset($opCacheStatus) || $opCacheStatus == false ? 0 : $opCacheStatus['opcache_statistics']['num_cached_scripts'];
     $opcacheSizeKb = (!isset($opCacheStatus) || $opCacheStatus == false ? 0 : $opCacheStatus['memory_usage']['used_memory']) / (1024 * 1024);
     $opcacheMaxSizeKb = isset($opCacheConfig['directives']['opcache.memory_consumption']) ? $opCacheConfig['directives']['opcache.memory_consumption'] / (1024 * 1024) : 0;
     $memcacheEntriesCount = isset($memcacheStats['curr_items']) ? $memcacheStats['curr_items'] : 0;
     $memcacheSizeMb = isset($memcacheStats['bytes']) ? $memcacheStats['bytes'] / (1024 * 1024) : 0;
     $memcacheMaxSizeMb = isset($memcacheStats['limit_maxbytes']) ? $memcacheStats['limit_maxbytes'] / (1024 * 1024) : 0;
     $memcacheConfiguration = $this->getMemcacheConfiguration();
     $memcacheServerKey = $memcacheConfiguration['ip'] . ':' . $memcacheConfiguration['port'];
     $memcachedServerEntriesCount = isset($memcachedStats[$memcacheServerKey]['curr_items']) ? $memcachedStats[$memcacheServerKey]['curr_items'] : 0;
     $memcachedServerSizeMb = isset($memcachedStats[$memcacheServerKey]['bytes']) ? $memcachedStats[$memcacheServerKey]['bytes'] / (1024 * 1024) : 0;
     $memcachedEntriesCount = $this->getMemcachedEntryCount();
     $memcachedSizeMb = $memcachedServerEntriesCount ? $memcachedServerSizeMb / $memcachedServerEntriesCount * $memcachedEntriesCount : 0;
     $memcachedMaxSizeMb = isset($memcachedStats[$memcacheServerKey]['limit_maxbytes']) ? $memcachedStats[$memcacheServerKey]['limit_maxbytes'] / (1024 * 1024) : 0;
     $this->objTpl->setVariable(array('SETTINGS_STATUS_ON' => $this->arrSettings['cacheEnabled'] == 'on' ? 'checked' : '', 'SETTINGS_STATUS_OFF' => $this->arrSettings['cacheEnabled'] == 'off' ? 'checked' : '', 'SETTINGS_OP_CACHE_STATUS_ON' => $this->arrSettings['cacheOpStatus'] == 'on' ? 'checked' : '', 'SETTINGS_OP_CACHE_STATUS_OFF' => $this->arrSettings['cacheOpStatus'] == 'off' ? 'checked' : '', 'SETTINGS_DB_CACHE_STATUS_ON' => $this->arrSettings['cacheDbStatus'] == 'on' ? 'checked' : '', 'SETTINGS_DB_CACHE_STATUS_OFF' => $this->arrSettings['cacheDbStatus'] == 'off' ? 'checked' : '', 'SETTINGS_CACHE_REVERSE_PROXY_NONE' => $this->arrSettings['cacheReverseProxy'] == 'none' ? 'selected' : '', 'SETTINGS_CACHE_REVERSE_PROXY_VARNISH' => $this->arrSettings['cacheReverseProxy'] == 'varnish' ? 'selected' : '', 'SETTINGS_CACHE_REVERSE_PROXY_NGINX' => $this->arrSettings['cacheReverseProxy'] == 'nginx' ? 'selected' : '', 'SETTINGS_SSI_CACHE_STATUS_INTERN' => $this->arrSettings['cacheSsiOutput'] == 'intern' ? 'selected' : '', 'SETTINGS_SSI_CACHE_STATUS_SSI' => $this->arrSettings['cacheSsiOutput'] == 'ssi' ? 'selected' : '', 'SETTINGS_SSI_CACHE_STATUS_ESI' => $this->arrSettings['cacheSsiOutput'] == 'esi' ? 'selected' : '', 'INTERNAL_SSI_CACHE_ON' => $this->arrSettings['internalSsiCache'] == 'on' ? 'checked' : '', 'INTERNAL_SSI_CACHE_OFF' => $this->arrSettings['internalSsiCache'] != 'on' ? 'checked' : '', 'SETTINGS_SSI_CACHE_TYPE_VARNISH' => $this->arrSettings['cacheSsiType'] == 'varnish' ? 'selected' : '', 'SETTINGS_SSI_CACHE_TYPE_NGINX' => $this->arrSettings['cacheSsiType'] == 'nginx' ? 'selected' : '', 'SETTINGS_EXPIRATION' => intval($this->arrSettings['cacheExpiration']), 'STATS_CONTREXX_FILESYSTEM_CHACHE_PAGES_COUNT' => $intFilesPages, 'STATS_FOLDERSIZE_PAGES' => number_format($intFoldersizePages / 1024, 2, '.', '\''), 'STATS_CONTREXX_FILESYSTEM_CHACHE_ENTRIES_COUNT' => $intFilesEntries, 'STATS_FOLDERSIZE_ENTRIES' => number_format($intFoldersizeEntries / 1024, 2, '.', '\''), 'STATS_APC_CHACHE_SITE_COUNT' => $apcSizeCount, 'STATS_APC_CHACHE_ENTRIES_COUNT' => $apcEntriesCount, 'STATS_APC_MAX_SIZE' => number_format($apcMaxSizeKb, 2, '.', '\''), 'STATS_APC_SIZE' => number_format($apcSizeKb, 2, '.', '\''), 'STATS_OPCACHE_CHACHE_SITE_COUNT' => $opcacheSizeCount, 'STATS_OPCACHE_SIZE' => number_format($opcacheSizeKb, 2, '.', '\''), 'STATS_OPCACHE_MAX_SIZE' => number_format($opcacheMaxSizeKb, 2, '.', '\''), 'STATS_MEMCACHE_CHACHE_ENTRIES_COUNT' => $memcacheEntriesCount, 'STATS_MEMCACHE_SIZE' => number_format($memcacheSizeMb, 2, '.', '\''), 'STATS_MEMCACHE_MAX_SIZE' => number_format($memcacheMaxSizeMb, 2, '.', '\''), 'STATS_MEMCACHED_CHACHE_ENTRIES_COUNT' => $memcachedEntriesCount, 'STATS_MEMCACHED_SIZE' => number_format($memcachedSizeMb, 2, '.', '\''), 'STATS_MEMCACHED_MAX_SIZE' => number_format($memcachedMaxSizeMb, 2, '.', '\'')));
     $objTemplate->setVariable(array('CONTENT_TITLE' => $_ARRAYLANG['TXT_SETTINGS_MENU_CACHE'], 'ADMIN_CONTENT' => $this->objTpl->get()));
 }
Esempio n. 14
0
 *
 */
// common include
include '/srv/http/app/config/config.php';
opcache_invalidate('/srv/http/command/cachectl.php');
// insect GET['action']
if (isset($_GET['action'])) {
    switch ($_GET['action']) {
        case 'prime':
            OpCacheCtl('prime', '/srv/http/', $redis);
            break;
        case 'primeall':
            OpCacheCtl('primeall', '/srv/http/');
            break;
        case 'reset':
            OpCacheCtl('reset', '/srv/http/');
            opcache_reset();
            runelog('cacheCTL RESET');
            echo "PHP OPCACHE CLEARED";
            break;
        case 'debug':
            // opcache_reset();
            echo "<pre>";
            echo "OPcache status:\n";
            print_r(opcache_get_status());
            echo "OPcache configuration:\n";
            print_r(opcache_get_configuration());
            echo "</pre>";
            break;
    }
}
Esempio n. 15
0
 function render_dashboard_widget()
 {
     $this->data['config'] = opcache_get_configuration();
     $this->data['status'] = opcache_get_status(false);
     $this->load_view('widgets/dashboard.php', $this->data);
 }
Esempio n. 16
0
 /**
  * Creates instance
  *
  * @param \OpCacheGUI\Format\Byte $byteFormatter Formatter of byte values
  */
 public function __construct(Byte $byteFormatter)
 {
     $this->byteFormatter = $byteFormatter;
     $this->configData = opcache_get_configuration();
 }
Esempio n. 17
0
 /**
  * Gets content panel for the Debugbar
  *
  * @return string
  */
 public function getPanel()
 {
     $panel = '';
     $linebreak = $this->getLinebreak();
     # Support for APC
     if (function_exists('apc_sma_info') && ini_get('apc.enabled')) {
         $mem = apc_sma_info();
         $memSize = $mem['num_seg'] * $mem['seg_size'];
         $memAvail = $mem['avail_mem'];
         $memUsed = $memSize - $memAvail;
         $cache = apc_cache_info();
         if ($cache['mem_size'] > 0) {
             $panel .= '<h4>APC ' . phpversion('apc') . ' Enabled</h4>';
             $panel .= round($memAvail / 1024 / 1024, 1) . 'M available, ' . round($memUsed / 1024 / 1024, 1) . 'M used' . $linebreak . $cache['num_entries'] . ' Files cached (' . round($cache['mem_size'] / 1024 / 1024, 1) . 'M)' . $linebreak . $cache['num_hits'] . ' Hits (' . round($cache['num_hits'] * 100 / ($cache['num_hits'] + $cache['num_misses']), 1) . '%)';
             //. $linebreak
             //. $cache['expunges'] . ' Expunges (cache full count)';
         }
     }
     if (function_exists('opcache_get_configuration')) {
         $opconfig = opcache_get_configuration();
         if ($opconfig['directives']['opcache.enable']) {
             $opstatus = opcache_get_status();
             $cache = $opstatus['opcache_statistics'];
             $panel .= '<h4>' . $opconfig['version']['opcache_product_name'] . ' ' . $opconfig['version']['version'] . ' Enabled</h4>';
             $panel .= round($opstatus['memory_usage']['used_memory'] / 1024 / 1024, 1) . 'M used, ' . round($opstatus['memory_usage']['free_memory'] / 1024 / 1024, 1) . 'M free (' . round($opstatus['memory_usage']['current_wasted_percentage'], 1) . '% wasted)' . $linebreak . $cache['num_cached_scripts'] . ' Files cached' . $linebreak . $cache['hits'] . ' Hits (' . round($cache['opcache_hit_rate'], 1) . '%)';
         }
     }
     foreach ($this->_cacheBackends as $name => $backend) {
         $fillingPercentage = $backend->getFillingPercentage();
         $ids = $backend->getIds();
         # Print full class name, backends might be custom
         $panel .= '<h4>Cache ' . $name . ' (' . get_class($backend) . ')</h4>';
         $panel .= count($ids) . ' Entr' . (count($ids) > 1 ? 'ies' : 'y') . '' . $linebreak . 'Filling Percentage: ' . $backend->getFillingPercentage() . '%' . $linebreak;
         $cacheSize = 0;
         foreach ($ids as $id) {
             # Calculate valid cache size
             $memPre = memory_get_usage();
             if ($cached = $backend->load($id)) {
                 $memPost = memory_get_usage();
                 $cacheSize += $memPost - $memPre;
                 unset($cached);
             }
         }
         $panel .= 'Valid Cache Size: ' . round($cacheSize / 1024, 1) . 'K';
     }
     return $panel;
 }
Esempio n. 18
0
 *
 */
define('AREA', 'admin');
require './lib/init.php';
if ($action == 'reset' && function_exists('opcache_reset') && $userinfo['change_serversettings'] == '1') {
    opcache_reset();
    $log->logAction(ADM_ACTION, LOG_INFO, "reseted OPcache");
    header('Location: ' . $linker->getLink(array('section' => 'opcacheinfo', 'page' => 'showinfo')));
    exit;
}
if (!function_exists('opcache_get_configuration')) {
    standard_error($lng['error']['no_opcacheinfo']);
    exit;
}
if ($page == 'showinfo') {
    $opcache_info = opcache_get_configuration();
    $opcache_status = opcache_get_status(false);
    $time = time();
    $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed OPcache info");
    $runtimelines = '';
    if (isset($opcache_info['directives']) && is_array($opcache_info['directives'])) {
        foreach ($opcache_info['directives'] as $name => $value) {
            $linkname = str_replace('_', '-', $name);
            if ($name == 'opcache.optimization_level' && is_integer($value)) {
                $value = '0x' . dechex($value);
            }
            if ($name == 'opcache.memory_consumption' && is_integer($value) && $value % (1024 * 1024) == 0) {
                $value = $value / (1024 * 1024);
            }
            if ($value === null || $value === '') {
                $value = $lng['opcacheinfo']['novalue'];
 public function __construct()
 {
     $this->configurationData = opcache_get_configuration();
 }
Esempio n. 20
0
 public function __construct()
 {
     $this->_configuration = opcache_get_configuration();
     $this->_status = opcache_get_status();
 }
Esempio n. 21
0
 /**
  * Gets content panel for the Debug Bar
  *
  * @return string
  */
 public function getPanel()
 {
     $panel = '';
     $linebreak = $this->getLinebreak();
     # Support for APC
     if (function_exists('apc_sma_info') && ini_get('apc.enabled')) {
         $mem = apc_sma_info();
         $memSize = $mem['num_seg'] * $mem['seg_size'];
         $memAvail = $mem['avail_mem'];
         $memUsed = $memSize - $memAvail;
         $cache = apc_cache_info();
         $numEntries = isset($cache['num_entries']) ? $cache['num_entries'] : 0;
         $numHits = isset($cache['num_hits']) ? $cache['num_hits'] : 0;
         $numMisses = isset($cache['num_misses']) ? $cache['num_misses'] : 0;
         $expunges = isset($cache['expunges']) ? $cache['expunges'] : '';
         if ($cache['mem_size'] > 0) {
             $panel .= '<h4>APC ' . phpversion('apc') . ' Enabled</h4>';
             $panel .= round($memAvail / 1024 / 1024, 1) . 'M available, ' . round($memUsed / 1024 / 1024, 1) . 'M used' . $linebreak . $numEntries . ' Files cached (' . round($cache['mem_size'] / 1024 / 1024, 1) . 'M)' . $linebreak . $numHits . ' Hits (' . round($numHits * 100 / ($numHits + $numMisses), 1) . '%)' . $linebreak . $expunges . ' Expunges (cache full count)';
         }
     }
     if (function_exists('opcache_get_configuration')) {
         $opconfig = opcache_get_configuration();
         if ($opconfig['directives']['opcache.enable']) {
             $opstatus = opcache_get_status();
             $cache = $opstatus['opcache_statistics'];
             $panel .= '<h4>' . $opconfig['version']['opcache_product_name'] . ' ' . $opconfig['version']['version'] . ' Enabled</h4>';
             $panel .= round($opstatus['memory_usage']['used_memory'] / 1024 / 1024, 1) . 'M used, ' . round($opstatus['memory_usage']['free_memory'] / 1024 / 1024, 1) . 'M free (' . round($opstatus['memory_usage']['current_wasted_percentage'], 1) . '% wasted)' . $linebreak . $cache['num_cached_scripts'] . ' Files cached' . $linebreak . $cache['hits'] . ' Hits (' . round($cache['opcache_hit_rate'], 1) . '%)';
         }
     }
     /** @var \Zend_Cache_Backend_ExtendedInterface $backend */
     foreach ($this->cacheBackends as $name => $backend) {
         $fillingPercentage = $backend->getFillingPercentage();
         $ids = $backend->getIds();
         # Print full class name, backends might be custom
         $panel .= '<h4>Cache ' . $name . ' (' . get_class($backend) . ')</h4>';
         $panel .= count($ids) . ' Entr' . (count($ids) > 1 ? 'ies' : 'y') . '' . $linebreak . 'Filling Percentage: ' . $fillingPercentage . '%' . $linebreak;
         $cacheSize = 0;
         foreach ($ids as $id) {
             # Calculate valid cache size
             $memPre = memory_get_usage();
             if ($cached = $backend->load($id)) {
                 $memPost = memory_get_usage();
                 $cacheSize += $memPost - $memPre;
                 unset($cached);
             }
         }
         $panel .= 'Valid Cache Size: ' . round($cacheSize / 1024, 1) . 'K';
     }
     // adds form to clear the cache
     $panel .= '<h4>Clear cache</h4>' . $linebreak . '<form method="post"><button name="clear_cache" type="submit" class="btn">Clear cache</button></form>';
     return $panel;
 }
Esempio n. 22
0
 function configuration()
 {
     \Kint::dump(opcache_get_configuration());
 }
Esempio n. 23
0
 public function config()
 {
     $config = opcache_get_configuration();
     return $config;
 }
Esempio n. 24
0
<?php

phpinfo();
var_dump(opcache_get_configuration());
var_dump(opcache_get_status());
Esempio n. 25
0
<?php

/**
 * Fetch configuration and status information from OpCache
 */
$config = opcache_get_configuration();
$status = opcache_get_status();
/**
 * Turn bytes into a human readable format
 * @param $bytes
 */
function size_for_humans($bytes)
{
    if ($bytes > 1048576) {
        return sprintf("%.2f&nbsp;MB", $bytes / 1048576);
    } elseif ($bytes > 1024) {
        return sprintf("%.2f&nbsp;kB", $bytes / 1024);
    } else {
        return sprintf("%d&nbsp;bytes", $bytes);
    }
}
function getOffsetWhereStringsAreEqual($a, $b)
{
    $i = 0;
    while (strlen($a) && strlen($b) && strlen($a) > $i && $a[$i] === $b[$i]) {
        $i++;
    }
    return $i;
}
function getSuggestionMessage($property, $value)
{
Esempio n. 26
0
 private function gather_metrics()
 {
     $opcache_stats = opcache_get_status();
     $opcache_conf = opcache_get_configuration();
     $opcache_stats['memory_usage']['percent_used'] = $opcache_stats['memory_usage']['used_memory'] / ($opcache_stats['memory_usage']['used_memory'] + $opcache_stats['memory_usage']['free_memory']) * 100;
     $this->metrics = array('agent' => array('host' => $this->hostname, 'pid' => $this->pid, 'version' => $this->version), 'components' => array(array('name' => $this->instance_name, 'guid' => $this->plugin_guid, 'duration' => $this->poll_cycle, 'metrics' => array('Component/PHPOPcache/Memory/Used[bytes]' => $opcache_stats['memory_usage']['used_memory'], 'Component/PHPOPcache/Memory/Free[bytes]' => $opcache_stats['memory_usage']['free_memory'], 'Component/PHPOPcache/Memory/Wasted[bytes]' => $opcache_stats['memory_usage']['wasted_memory'], 'Component/PHPOPcache/Memory/PercentUsed[percent]' => $opcache_stats['memory_usage']['percent_used'], 'Component/PHPOPcache/Cache/TotalScripts[scripts]' => $opcache_stats['opcache_statistics']['num_cached_scripts'], 'Component/PHPOPcache/Cache/HitRate[percent]' => $opcache_stats['opcache_statistics']['opcache_hit_rate'], 'Component/PHPOPcache/Cache/Keys/Current[keys]' => $opcache_stats['opcache_statistics']['num_cached_keys'], 'Component/PHPOPcache/Cache/Keys/Max[keys]' => $opcache_stats['opcache_statistics']['max_cached_keys'], 'Component/PHPOPcache/Cache/Scripts/Hits[scripts]' => $opcache_stats['opcache_statistics']['hits'], 'Component/PHPOPcache/Cache/Scripts/Misses[scripts]' => $opcache_stats['opcache_statistics']['misses'], 'Component/PHPOPcache/Cache/Blacklist/Misses[bscripts]' => $opcache_stats['opcache_statistics']['blacklist_misses'], 'Component/PHPOPcache/Cache/Restarts/OOM[restarts]' => $opcache_stats['opcache_statistics']['oom_restarts'], 'Component/PHPOPcache/Cache/Restarts/Hash[restarts]' => $opcache_stats['opcache_statistics']['hash_restarts'], 'Component/PHPOPcache/Cache/Restarts/Manual[restarts]' => $opcache_stats['opcache_statistics']['manual_restarts']))));
     return true;
 }
Esempio n. 27
0
 protected function compileState()
 {
     $status = opcache_get_status();
     $config = opcache_get_configuration();
     $files = [];
     if (!empty($status['scripts'])) {
         uasort($status['scripts'], function ($a, $b) {
             return $a['hits'] < $b['hits'];
         });
         foreach ($status['scripts'] as &$file) {
             $file['full_path'] = str_replace('\\', '/', $file['full_path']);
             $file['readable'] = ['hits' => number_format($file['hits']), 'memory_consumption' => $this->size($file['memory_consumption'])];
         }
         $files = array_values($status['scripts']);
     }
     $overview = array_merge($status['memory_usage'], $status['opcache_statistics'], ['used_memory_percentage' => round(100 * (($status['memory_usage']['used_memory'] + $status['memory_usage']['wasted_memory']) / $config['directives']['opcache.memory_consumption'])), 'hit_rate_percentage' => round($status['opcache_statistics']['opcache_hit_rate']), 'wasted_percentage' => round($status['memory_usage']['current_wasted_percentage'], 2), 'readable' => ['total_memory' => $this->size($config['directives']['opcache.memory_consumption']), 'used_memory' => $this->size($status['memory_usage']['used_memory']), 'free_memory' => $this->size($status['memory_usage']['free_memory']), 'wasted_memory' => $this->size($status['memory_usage']['wasted_memory']), 'num_cached_scripts' => number_format($status['opcache_statistics']['num_cached_scripts']), 'hits' => number_format($status['opcache_statistics']['hits']), 'misses' => number_format($status['opcache_statistics']['misses']), 'blacklist_miss' => number_format($status['opcache_statistics']['blacklist_misses']), 'num_cached_keys' => number_format($status['opcache_statistics']['num_cached_keys']), 'max_cached_keys' => number_format($status['opcache_statistics']['max_cached_keys']), 'start_time' => date_format(date_create("@{$status['opcache_statistics']['start_time']}"), 'Y-m-d H:i:s'), 'last_restart_time' => $status['opcache_statistics']['last_restart_time'] == 0 ? 'never' : date_format(date_create("@{$status['opcache_statistics']['last_restart_time']}"), 'Y-m-d H:i:s')]]);
     $directives = [];
     ksort($config['directives']);
     foreach ($config['directives'] as $k => $v) {
         $directives[] = ['k' => $k, 'v' => $v];
     }
     $version = array_merge($config['version'], ['php' => phpversion(), 'server' => $_SERVER['SERVER_SOFTWARE'], 'host' => function_exists('gethostname') ? gethostname() : (php_uname('n') ?: (empty($_SERVER['SERVER_NAME']) ? $_SERVER['HOST_NAME'] : $_SERVER['SERVER_NAME']))]);
     return ['version' => $version, 'overview' => $overview, 'files' => $files, 'directives' => $directives, 'blacklist' => $config['blacklist'], 'functions' => get_extension_funcs('Zend OPcache')];
 }
Esempio n. 28
0
 public function configuration()
 {
     $raw = opcache_get_configuration();
     $this->result['config'] = $raw;
 }