get server ram with php

后端 未结 9 1615
抹茶落季
抹茶落季 2020-12-05 00:19

Is there a way to know the avaliable ram in a server (linux distro) with php (widthout using linux commands)?

edit: sorry, the objective is to be aware of the ram av

9条回答
  •  北海茫月
    2020-12-05 00:38

    Using /proc/meminfo and getting everything into an array is simple:

    
    

    var_dump( getSystemMemInfo() );

    array(43) {
      ["MemTotal"]=>
      string(10) "2060700 kB"
      ["MemFree"]=>
      string(9) "277344 kB"
      ["Buffers"]=>
      string(8) "92200 kB"
      ["Cached"]=>
      string(9) "650544 kB"
      ["SwapCached"]=>
      string(8) "73592 kB"
      ["Active"]=>
      string(9) "995988 kB"
      ...
    

提交回复
热议问题