hdd.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2017 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. if( isset($_GET['remote_server_id']) AND $os != "nocpu" )
  25. {
  26. require_once('includes/lib_remote.php');
  27. $rhost_id = $_GET['remote_server_id'];
  28. $remote_server = $db->getRemoteServer($rhost_id);
  29. $remote = new OGPRemoteLibrary($remote_server['agent_ip'], $remote_server['agent_port'], $remote_server['encryption_key'], $remote_server['timeout']);
  30. $disk_info = $remote->shell_action('get_disk_usage' , 'sum');
  31. $free = $disk_info['free'];
  32. $used = $disk_info['used'];
  33. $total = $disk_info['total'];
  34. $percent = $disk_info['percent'];
  35. }
  36. else
  37. {
  38. if($os == "windows")
  39. {
  40. $total = disk_total_space("./");
  41. $free = disk_free_space("./");
  42. $used = $total - $free;
  43. }
  44. else
  45. {
  46. if($cygwin)
  47. $disk_info = shell_exec('df -lP|grep "^.:\s"|awk \'{size+=$2}{used+=$3}{avail+=$4} END {print size, used, avail}\'');
  48. else
  49. $disk_info = shell_exec('df -lP|grep "^/dev/.*"|awk \'{size+=$2}{used+=$3}{avail+=$4} END {print size, used, avail}\'');
  50. list($totalKB, $usedKB, $freeKB) = explode(" ", $disk_info);
  51. $free = 1024*$freeKB;
  52. $used = 1024*$usedKB;
  53. $total = 1024*$totalKB;
  54. }
  55. $percent = 100 * $used / $total;
  56. }
  57. $diskspace = numbersFormatting($total);
  58. $diskinuse = numbersFormatting($used) . ' (' . round($percent, "2") . '%)';
  59. $hddbarusage = round($percent, "2");
  60. $hddfreespace = numbersFormatting($free);
  61. ?>