Ein Snippet welches euch ein paar aktuelle Daten eueres Servers/Systems anzeigt. So z.B. System Information, CPU Information, Memory Usage, Disk Usage und Uptime:

<pre>
<b>Uptime:</b>
<?php

$foo = exec('cat /proc/uptime');
preg_match("/(.*) (.*)/",$foo, $matches);
$sek = round($matches[1]);
$n = date_create('now', new DateTimeZone('GMT'));
$d = clone $n;
$d->modify($sek . ' seconds');
$diff = $n->diff($d);

echo $diff->format('%a day(s) %h hour(s) %i minute(s) %s second(s)');

?>

<b>System Information:</b>
<?php system("uname -a"); ?>

<b>Memory Usage (MB):</b>
<?php system("free -m"); ?>

<b>Disk Usage:</b>
<?php system("df -h"); ?>

<b>CPU Information:</b>
<?php system("cat /proc/cpuinfo | grep \"model name\\|processor\""); ?>
</pre>


No votes yet.
Please wait...
Posted on: 22. Februar 2015
Categories: PHP Snippets

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.