Home » Php » linux – Get disk usage (load) in percentage with PHP

linux – Get disk usage (load) in percentage with PHP

Posted by: admin February 25, 2020 Leave a comment


I have a dedicated Linux server that is currently hosting a few games.
I recently started to code on a control panel written in PHP and I would like to be able to display the disk load in this control panel.

How can I get the disk usage (load) in percentages using PHP under Linux?

If it helps, I am the owner of this dedicated machine and I can install any packages you might suggest.

How to&Answers:
// $df contains the number of bytes available on "/"
$df = disk_free_space("/");

// On Windows:
$df_c = disk_free_space("C:");
$df_d = disk_free_space("D:");

Refer the below link for more details, https://www.php.net/manual/en/function.disk-free-space.php