Advertisement
killermist

disk_use.php

Jul 30th, 2012
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.97 KB | None | 0 0
  1. cat disk_use.php
  2. <?php
  3. /*
  4.     online status.php scripts
  5.  
  6.     based on the scripts of Matthew Miller, Aug 2009.
  7.  
  8.     Modified and improved by Cornelis Oud.
  9.     Copyright (C) 2010.
  10.    
  11.     Modified and improved by Michael Zoon
  12.     Copyright (C) 2012 Michael Zoon <michael.zoon@freenas.org>.
  13.     All rights reserved.
  14.  
  15.     Webservice plugin for FreeNAS (http://www.freenas.org)
  16.     FreeNAS Copyright (C) 2005-2012 Olivier Cochard-Labbe <olivier@freenas.org>.
  17.     All rights reserved.
  18.  
  19.     Redistribution and use in source and binary forms, with or without
  20.     modification, are permitted provided that the following conditions are met:
  21.  
  22.     1. Redistributions of source code must retain the above copyright notice,
  23.        this list of conditions and the following disclaimer.
  24.  
  25.     2. Redistributions in binary form must reproduce the above copyright
  26.        notice, this list of conditions and the following disclaimer in the
  27.        documentation and/or other materials provided with the distribution.
  28.  
  29.     THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
  30.     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  31.     AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  32.     AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  33.     OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  34.     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  35.     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  36.     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  37.     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38.     POSSIBILITY OF SUCH DAMAGE.
  39. */
  40.  
  41. include_once("bar.php");
  42.  
  43. putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin/");
  44.  
  45. function DiskUse()
  46. {
  47. //  $out = "<fieldset><legend>Disk Usage</legend><table border=1>";
  48. //  $out .= "<tr>";
  49. //  $out .= "<th>Filesystem</th>";
  50. //  $out .= "<th>Size</th>";
  51. //  $out .= "<th>Used</th>";
  52. //  $out .= "<th>Free</th>";
  53. //  $out .= "<th>Capacity</th>";
  54. //  $out .= "<th>Mounted</th>";
  55. //  $out .= "</tr>";
  56.  
  57.   // Invoke bsd command
  58.   $stats = `df -hT`;
  59.   // Clean up the string
  60. //  while(strpos($stats, "  "))
  61. //    $stats = trim(str_replace("  ", " ", $stats));
  62.   // Convert to array
  63. //  $stats = explode("\n", $stats);
  64.  
  65. //  for($i = 1; $i < count($stats); $i++)
  66. //  {
  67. //    $row = explode(" ", $stats[$i]);
  68. //    if($row[0] != "devfs" && $row[0] != "procfs")
  69. //    {
  70. //      $out .= "<tr>";
  71. //      $out .= "<td>".$row[0]."</td>";
  72. //      $out .= "<td>".$row[1]."</td>";
  73. //      $out .= "<td>".$row[2]."</td>";
  74. //      $out .= "<td>".$row[3]."</td>";
  75. //      $out .= "<td>".inline_bar("", percent_bar(substr($row[4], 0, -1)), $row[4])."</td>";
  76. //      $out .= "<td>".$row[5]."</td>";
  77. //      $out .= "</tr>";
  78. //    }  
  79. //  }
  80. //  $out .= "</table></fieldset>\n\n";
  81.   $out = "<fieldset><legend>Disk Usage</legend><pre>";
  82.   $out .= $stats;
  83.   $out .= "</pre></fieldset>\n\n";
  84.   return $out;
  85. }
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement