Created
January 31, 2018 21:30
-
-
Save LABCAT/b242e1d67d9fbe5a7c02d84db19066a8 to your computer and use it in GitHub Desktop.
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
/* Gets server memory usage, can be used to debug how much memory a script is using */ | |
function get_server_memory_usage(){ | |
$free = shell_exec('free -m'); | |
$free = (string)trim($free); | |
$free_arr = explode("\n", $free); | |
$mem = explode(" ", $free_arr[1]); | |
$mem = array_filter($mem); | |
$mem = array_merge($mem); | |
$memory_usage = "used: " . $mem[2] . "\n"; | |
$memory_usage .= "free: " . $mem[2] . "\n"; | |
return $memory_usage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment