It is currently Tue May 22, 2018 7:37 am


All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: [PHP] Disk Space Scripts
PostPosted: Sun Jan 15, 2006 5:16 pm 
I have created a PHP script that calculates the amount of disk space left on a web server hard drive, although this would theortically be useless for end users, but it can be used by server admins to monitor disk space usage.

Code:
<?php
/*
PHP Disk Space Stats
Author: rm249
Site: http://www.rm249.com/
*/
?>
<html>
<head>
<title>Disk Statistics</title>
</head>
<body>
<?
$dt=disk_total_space("/");
$df=disk_free_space("/");
$total_space=round($dt/1024/1024/1024, 2);
$total_free=round($df/1024/1024/1024, 2);
$total_used=$total_space-$total_free;
$percent_free=round(($total_free/$total_space)*100, 2);
$percent_used=round(($total_used/$total_space)*100, 2);
if($percent_free < 10){
$disk_status = "<font color=\"red\"><b>WARNING: DISK SPACE LOW!</b></font>";
}else{
$disk_status = "<font color=\"green\"><b>Disk Space Okay!</b></font>";
}
?>
<table cols="2" width="500">
<tr>
  <td><b>Total Disk Space:</b></td>
  <td><? echo "$total_space "."GB"; ?></td>
</tr>
<tr>
  <td><b>Total Free Disk Space:</b></td>
  <td><? echo "$total_free "."GB"; ?></td>
</tr>
<tr>
  <td><b>Total Disk Space Used:</b></td>
  <td><? echo "$total_used "."GB"; ?></td>
</tr>
<tr>
  <td><b>Percent Used:</b></td>
  <td><? echo "$percent_used"."% Used"; ?></td>
</tr>
<tr>
  <td><b>Percent Free:</b></td>
  <td><? echo "$percent_free"."% Free"; ?></td>
</tr>
<tr>
  <td><b>Status:</b></td>
  <td><? echo $disk_status; ?></td>
</tr>
</table>
</body>
</html>


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ]  Moderators: fhmagic, KJ, Support Team, Moderators

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
100WebSpace © 2011