Last active
February 12, 2019 12:45
-
-
Save nurullahisik/6664ca53faec666f9415e7e2e31569e9 to your computer and use it in GitHub Desktop.
get server ram with php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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