From e43432a0fbb769f400532e3e1f591f02819fe7be Mon Sep 17 00:00:00 2001 From: Gemorroj Date: Sat, 28 Jul 2018 17:33:41 +0300 Subject: [PATCH] add more opcache & php info --- composer.json | 2 +- src/Info.php | 9 +++ src/Info/Php.php | 60 ++++++++++++++++++ src/Info/Php/Opcache.php | 130 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 200 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ab087f44..200f961e 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ }, "require-dev": { "phpunit/phpunit": "^7.1.2", - "phpstan/phpstan": "^0.9" + "phpstan/phpstan": "^0.10" }, "autoload": { "psr-4": { diff --git a/src/Info.php b/src/Info.php index 22a0427c..86a7d4bd 100644 --- a/src/Info.php +++ b/src/Info.php @@ -220,7 +220,10 @@ public function getPhp() : Php ->setExtensions(\get_loaded_extensions()) ->setZendExtensions(\get_loaded_extensions(true)) ->setIniFile(\php_ini_loaded_file()) + ->setMemoryLimit(Common::convertHumanSizeToBytes(\ini_get('memory_limit'))) ->setIncludePath(\get_include_path()) + ->setOpenBasedir(\ini_get('open_basedir')) + ->setZendThreadSafe(\ZEND_THREAD_SAFE) ->setSapiName(\PHP_SAPI) ->setDisabledFunctions($disabledFunctions ? \explode(',', $disabledFunctions) : []) ->setDisabledClasses($disabledClasses ? \explode(',', $disabledClasses) : []) @@ -237,6 +240,12 @@ public function getPhp() : Php ->setUsedMemory($opcacheStatus['memory_usage']['used_memory'] ?? null) ->setHits($opcacheStatus['opcache_statistics']['hits'] ?? null) ->setMisses($opcacheStatus['opcache_statistics']['misses'] ?? null) + ->setOomRestarts($opcacheStatus['opcache_statistics']['oom_restarts'] ?? null) + ->setHashRestarts($opcacheStatus['opcache_statistics']['hash_restarts'] ?? null) + ->setHashRestarts($opcacheStatus['opcache_statistics']['manual_restarts'] ?? null) + ->setCachedInternedStrings($opcacheStatus['interned_strings_usage']['number_of_strings'] ?? null) + ->setInternedStringsFreeMemory($opcacheStatus['interned_strings_usage']['free_memory'] ?? null) + ->setInternedStringsUsedMemory($opcacheStatus['interned_strings_usage']['used_memory'] ?? null) ) ->setApcu( (new Php\Apcu()) diff --git a/src/Info/Php.php b/src/Info/Php.php index 72bda29a..2fb25094 100644 --- a/src/Info/Php.php +++ b/src/Info/Php.php @@ -18,6 +18,8 @@ class Php /** @var string */ private $includePath; /** @var string */ + private $openBasedir; + /** @var string */ private $sapiName; /** @var Opcache */ private $opcache; @@ -31,6 +33,46 @@ class Php private $realpathCacheSizeUsed; /** @var float|null */ private $realpathCacheSizeAllowed; + /** @var bool */ + private $zendThreadSafe; + /** @var int */ + private $memoryLimit; + + /** + * @return int + */ + public function getMemoryLimit(): int + { + return $this->memoryLimit; + } + + /** + * @param int $memoryLimit + * @return $this + */ + public function setMemoryLimit(int $memoryLimit): self + { + $this->memoryLimit = $memoryLimit; + return $this; + } + + /** + * @return bool + */ + public function isZendThreadSafe(): bool + { + return $this->zendThreadSafe; + } + + /** + * @param bool $zendThreadSafe + * @return $this + */ + public function setZendThreadSafe(bool $zendThreadSafe): self + { + $this->zendThreadSafe = $zendThreadSafe; + return $this; + } /** * @return string @@ -122,6 +164,24 @@ public function setIncludePath(string $includePath): self return $this; } + /** + * @return string + */ + public function getOpenBasedir(): string + { + return $this->openBasedir; + } + + /** + * @param string $openBasedir + * @return $this + */ + public function setOpenBasedir(string $openBasedir): self + { + $this->openBasedir = $openBasedir; + return $this; + } + /** * @return string */ diff --git a/src/Info/Php/Opcache.php b/src/Info/Php/Opcache.php index b8564fa1..d18a3ce6 100644 --- a/src/Info/Php/Opcache.php +++ b/src/Info/Php/Opcache.php @@ -22,6 +22,136 @@ class Opcache private $misses; /** @var string|null */ private $version; + /** @var int|null */ + private $internedStringsUsedMemory; + /** @var int|null */ + private $internedStringsFreeMemory; + /** @var int|null */ + private $cachedInternedStrings; + + /** + * @return int|null + */ + public function getInternedStringsUsedMemory(): ?int + { + return $this->internedStringsUsedMemory; + } + + /** + * @param int|null $internedStringsUsedMemory + * @return $this + */ + public function setInternedStringsUsedMemory(?int $internedStringsUsedMemory): self + { + $this->internedStringsUsedMemory = $internedStringsUsedMemory; + return $this; + } + + /** + * @return int|null + */ + public function getInternedStringsFreeMemory(): ?int + { + return $this->internedStringsFreeMemory; + } + + /** + * @param int|null $internedStringsFreeMemory + * @return $this + */ + public function setInternedStringsFreeMemory(?int $internedStringsFreeMemory): self + { + $this->internedStringsFreeMemory = $internedStringsFreeMemory; + return $this; + } + + /** + * @return int|null + */ + public function getCachedInternedStrings(): ?int + { + return $this->cachedInternedStrings; + } + + /** + * @param int|null $cachedInternedStrings + * @return $this + */ + public function setCachedInternedStrings(?int $cachedInternedStrings): self + { + $this->cachedInternedStrings = $cachedInternedStrings; + return $this; + } + + /** + * @var int|null + * number of restarts because of out of memory + */ + private $oomRestarts; + /** + * @var int|null + * number of restarts because of hash overflow + */ + private $hashRestarts; + /** + * @var int|null + * number of restarts scheduled by opcache_reset() + */ + private $manualRestarts; + + /** + * @return int|null + */ + public function getOomRestarts(): ?int + { + return $this->oomRestarts; + } + + /** + * @param int|null $oomRestarts + * @return $this + */ + public function setOomRestarts(?int $oomRestarts): self + { + $this->oomRestarts = $oomRestarts; + return $this; + } + + /** + * @return int|null + */ + public function getHashRestarts(): ?int + { + return $this->hashRestarts; + } + + /** + * @param int|null $hashRestarts + * @return $this + */ + public function setHashRestarts(?int $hashRestarts): self + { + $this->hashRestarts = $hashRestarts; + return $this; + } + + /** + * @return int|null + */ + public function getManualRestarts(): ?int + { + return $this->manualRestarts; + } + + /** + * @param int|null $manualRestarts + * @return $this + */ + public function setManualRestarts(?int $manualRestarts): self + { + $this->manualRestarts = $manualRestarts; + return $this; + } /** * @return bool