suchen
Heimphp教程php手册PHP查看服务器信息内存、负载等

PHP查看服务器信息内存、负载等

Jun 06, 2016 pm 08:08 PM
php信息内存Kann服务器查看负载

PHP可以用来管理服务器的进程,执行系统命令等,所以查看服务器的内存、负载等就更易如反掌了。 有2种方法可以实现查询。 PHP exec exec() 可以执行给定的命令。 比如运行以下: ?php echo exec(whoami) . br; echo exec(git version) . br; echo exec(cat /

PHP可以用来管理服务器的进程,执行系统命令等,所以查看服务器的内存、负载等就更易如反掌了。

server info of 服务器运行时间 系统负载 内存

有2种方法可以实现查询。

PHP exec

exec() 可以执行给定的命令。

比如运行以下:

<?php echo exec(&#8216;whoami&#8217;) . &#8216;<br>’; echo exec(‘git –version’) . ‘<br>’; echo exec(‘cat /proc/uptime’) . ‘<br>’; echo exec(‘cat /proc/meminfo’) . ‘<br>’; echo exec(‘cat /proc/loadavg’) . ‘<br>’; ?>

结果是:

www git version 1.7.1 221601.89 879803.10 DirectMap2M: 2088960 kB 0.39 0.24 0.21 1/167 5584

这个函数可以轻松的实现在服务器上执行一个命令,非常关键,一定要小心使用。

但是其缺陷是返回值不太好处理。

PHP file_get_contents 或者 file

file_get_contents 函数可以将整个文件读入一个字符串,方便处理。

file 函数可以整个文件读入一个数组中。

例如在PHP探针文件中使用file函数读取的。

但是如果服务器限制了open_basedir,将会遇到以下错误。

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/proc/loadavg) is not within the allowed path(s): (/home/wwwroot/blog_lixiphp_com:/tmp) in /home/wwwroot/blog_lixiphp_com/public_html/test/inc/fun.inc.php on line 196

解决方法是在虚拟目录中关闭open_basedir。

(...)
Read the rest of PHP查看服务器信息内存、负载等 (13 words)


© lixiphp for LixiPHP, 2013. | Permalink | No comment | Add to del.icio.us
Post tags: command, Linux, PHP, 内存, 服务器, 负载

Feed enhanced by Better Feed from Ozh

Stellungnahme
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

AI Hentai Generator

AI Hentai Generator

Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Beste grafische Einstellungen
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Crossplay haben?
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌

Heiße Werkzeuge

SublimeText3 Linux neue Version

SublimeText3 Linux neue Version

SublimeText3 Linux neueste Version

EditPlus chinesische Crack-Version

EditPlus chinesische Crack-Version

Geringe Größe, Syntaxhervorhebung, unterstützt keine Code-Eingabeaufforderungsfunktion

PHPStorm Mac-Version

PHPStorm Mac-Version

Das neueste (2018.2.1) professionelle, integrierte PHP-Entwicklungstool

MinGW – Minimalistisches GNU für Windows

MinGW – Minimalistisches GNU für Windows

Dieses Projekt wird derzeit auf osdn.net/projects/mingw migriert. Sie können uns dort weiterhin folgen. MinGW: Eine native Windows-Portierung der GNU Compiler Collection (GCC), frei verteilbare Importbibliotheken und Header-Dateien zum Erstellen nativer Windows-Anwendungen, einschließlich Erweiterungen der MSVC-Laufzeit zur Unterstützung der C99-Funktionalität. Die gesamte MinGW-Software kann auf 64-Bit-Windows-Plattformen ausgeführt werden.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Leistungsstarke integrierte PHP-Entwicklungsumgebung