Skip to content

Instantly share code, notes, and snippets.

@batazo
Created June 26, 2025 15:54
Show Gist options
  • Save batazo/95bdafbda7b88198e678c808743e99ca to your computer and use it in GitHub Desktop.
Save batazo/95bdafbda7b88198e678c808743e99ca to your computer and use it in GitHub Desktop.
PHP SERVER STAT
<?php
$bootTimestamp = time() - (int) file_get_contents('/proc/uptime');
echo "<br/>";
echo "Indulás ideje: " . date('Y-m-d H:i:s', $bootTimestamp);
echo "<br/>";
$uptimeSeconds = (int) file_get_contents('/proc/uptime');
$days = floor($uptimeSeconds / 86400);
$hours = floor(($uptimeSeconds % 86400) / 3600);
$minutes = floor(($uptimeSeconds % 3600) / 60);
$seconds = $uptimeSeconds % 60;
echo "<br/>";
echo "Uptime: {$days} nap, {$hours} óra, {$minutes} perc, {$seconds} másodperc";
echo "<br/>";
$load = sys_getloadavg();
echo "<br/>";
echo "1 perces load: {$load[0]}\n";
echo "5 perces load: {$load[1]}\n";
echo "15 perces load: {$load[2]}\n";
echo "<br/>";
function getMemoryUsage()
{
$data = file_get_contents("/proc/meminfo");
$lines = explode("\n", $data);
$memInfo = [];
foreach ($lines as $line) {
if (preg_match('/^(\w+):\s+(\d+)\s+kB$/', $line, $matches)) {
$memInfo[$matches[1]] = (int)$matches[2];
}
}
$total = $memInfo['MemTotal'] ?? 0;
$free = $memInfo['MemFree'] ?? 0;
$buffers = $memInfo['Buffers'] ?? 0;
$cached = $memInfo['Cached'] ?? 0;
$used = $total - $free - $buffers - $cached;
return [
'total' => round($total / 1024, 2), // MB
'used' => round($used / 1024, 2),
'cached' => round($cached / 1024, 2),
'buffers' => round($buffers / 1024, 2),
'free' => round(($free + $buffers + $cached) / 1024, 2)
];
}
$memory = getMemoryUsage();
echo "<br/>";
echo "Teljes memória: {$memory['total']} MB\n";
echo "Használt memória: {$memory['used']} MB\n";
echo "Cached memória: {$memory['cached']} MB\n";
echo "Buffer memória: {$memory['buffers']} MB\n";
echo "Szabad memória: {$memory['free']} MB\n";
echo "<br/>";
$path = "/"; // vagy pl. "/var/www" vagy "C:/"
$totalSpace = disk_total_space($path);
$freeSpace = disk_free_space($path);
$usedSpace = $totalSpace - $freeSpace;
echo "<br/>";
echo "Teljes méret: " . round($totalSpace / 1024 / 1024 / 1024, 2) . " GB\n";
echo "Szabad: " . round($freeSpace / 1024 / 1024 / 1024, 2) . " GB\n";
echo "Használt: " . round($usedSpace / 1024 / 1024 / 1024, 2) . " GB\n";
echo "Kihasználtság: " . round(($usedSpace / $totalSpace) * 100, 2) . "%\n";
echo "<br/>";
$processCount = (int) shell_exec("ps -e --no-headers | wc -l");
echo "<br/>";
echo "Futó processzek száma: $processCount";
echo "<br/>";
$cpuInfo = file_get_contents('/proc/cpuinfo');
preg_match('/model name\s+:\s+(.+)/', $cpuInfo, $model);
preg_match('/cpu MHz\s+:\s+(.+)/', $cpuInfo, $mhz);
$cpuModel = $model[1] ?? 'N/A';
$cpuClock = $mhz[1] ?? 'N/A';
echo "<br/>";
echo "CPU típus: $cpuModel\n";
echo "Órajel: $cpuClock MHz\n";
echo "<br/>";
$cpuinfo = file_get_contents('/proc/cpuinfo');
$cores = preg_match_all('/^processor/m', $cpuinfo);
echo "<br/>";
echo "CPU magok száma: $cores";
echo "<br/>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment