Skip to content

Instantly share code, notes, and snippets.

@nurullahisik
Last active February 12, 2019 12:45
Show Gist options
  • Select an option

  • Save nurullahisik/6664ca53faec666f9415e7e2e31569e9 to your computer and use it in GitHub Desktop.

Select an option

Save nurullahisik/6664ca53faec666f9415e7e2e31569e9 to your computer and use it in GitHub Desktop.
get server ram with php
<?php
$fh = fopen('/proc/meminfo','r');
$mem = 0;
while ($line = fgets($fh)) {
$pieces = array();
if (preg_match('/^MemTotal:\s+(\d+)\skB$/', $line, $pieces)) {
$mem = $pieces[1];
break;
}
}
fclose($fh);
echo "$mem kB RAM found";
?>
// result
255908 kB RAM found
resource : https://stackoverflow.com/questions/1455379/get-server-ram-with-php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment