Welcome to Geeklog, Anonymous Monday, December 30 2024 @ 11:04 am EST
Geeklog Forums
Check Quota block
Status: offline
daveshorts
Forum User
Newbie
Registered: 09/23/03
Posts: 7
I have written a little block to check that you are not overquota. I think it will only work on linux/unix systems that have a quota command, that formats the result in a standard way.
It will list your used space, quota, and freespace. As the freespace is less than $worry, $panic, and 0 it will write the freespace bigger and redder.
I don't know how useful it is, but hey
Put this code in lib_custom . Then in put 'phpblock_checkQuota' in the PHPblock section of the block, and hopefully it will work.
You will probably want to change $hd to the hard drive you are using (without /dev/) and change $worry, and $panic
*
* Check quota()
*
* Php function to tell you if you are going overquota
* Will probably only work on unix systems
**/
function phpblock_checkQuota(){
// The hard disk you are interested in
$hd='hda10';
// when the free space should be in red
$worry=1000;
// when the free space should be in red and large
$panic=10;
$string=exec('quota');
preg_match("/$hds*(d*)s*(d*)s*(d*)s{1,7}(d*)/",$string,$matches);
$freespace=$matches[2]-$matches[1];
$return.= "<tr><td>used</td><td align=right>$matches[1] kB</td></tr>
<tr><td>quota</td><td align=right>$matches[2] kB</td></td>";
if($freespace<$panic){
$return.= "<tr><td><b>Free</></td><td align=right><b><font color=red size=6>$freespace</font></b> kB</td></tr>";}
elseif($freespace<$worry){
$return.= "<tr><td><b>Free</b></td><td align=right><font color=red>$freespace kB</font></td></tr>";}
elseif($freespace<0){
$return.= "<tr><td><b>Free</b></td><td align=right><font color=red>$freespace kB</font></td></tr>
<tr><b>Grace</b></td><td align=right><font color=red>$matches[4]</font></td></tr>";
}
else{
$return.= "<tr><td><b>Free</b></td><td align=right>$freespace kB</td></tr>";
}
return $return;
}
It will list your used space, quota, and freespace. As the freespace is less than $worry, $panic, and 0 it will write the freespace bigger and redder.
I don't know how useful it is, but hey
Put this code in lib_custom . Then in put 'phpblock_checkQuota' in the PHPblock section of the block, and hopefully it will work.
You will probably want to change $hd to the hard drive you are using (without /dev/) and change $worry, and $panic
Text Formatted Code
/***
* Check quota()
*
* Php function to tell you if you are going overquota
* Will probably only work on unix systems
**/
function phpblock_checkQuota(){
// The hard disk you are interested in
$hd='hda10';
// when the free space should be in red
$worry=1000;
// when the free space should be in red and large
$panic=10;
$string=exec('quota');
preg_match("/$hds*(d*)s*(d*)s*(d*)s{1,7}(d*)/",$string,$matches);
$freespace=$matches[2]-$matches[1];
$return.= "<tr><td>used</td><td align=right>$matches[1] kB</td></tr>
<tr><td>quota</td><td align=right>$matches[2] kB</td></td>";
if($freespace<$panic){
$return.= "<tr><td><b>Free</></td><td align=right><b><font color=red size=6>$freespace</font></b> kB</td></tr>";}
elseif($freespace<$worry){
$return.= "<tr><td><b>Free</b></td><td align=right><font color=red>$freespace kB</font></td></tr>";}
elseif($freespace<0){
$return.= "<tr><td><b>Free</b></td><td align=right><font color=red>$freespace kB</font></td></tr>
<tr><b>Grace</b></td><td align=right><font color=red>$matches[4]</font></td></tr>";
}
else{
$return.= "<tr><td><b>Free</b></td><td align=right>$freespace kB</td></tr>";
}
return $return;
}
17
13
Quote
All times are EST. The time is now 11:04 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content