[vhffs-dev] [svn] commit: r174 - /trunk/vhffs-robots/src/update_quota_used.pl |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Author: soda
Date: Tue Mar 28 21:16:39 2006
New Revision: 174
Log:
Put a new robot who put the used quota
Modified:
trunk/vhffs-robots/src/update_quota_used.pl
Modified: trunk/vhffs-robots/src/update_quota_used.pl
==============================================================================
--- trunk/vhffs-robots/src/update_quota_used.pl (original)
+++ trunk/vhffs-robots/src/update_quota_used.pl Tue Mar 28 21:16:39 2006
@@ -20,26 +20,57 @@
my $inodes;
my $cmd;
my $quota;
+my $line;
+
+#$bu is the blocks used
+my $bu;
+
+#$su is the space used
+my $su;
foreach $group ( @{$groups} )
{
if( $group->fetch > 0 )
{
+ $bu = undef;
$blocks = $group->get_quota * 1024;
$inodes = $group->get_quota * 1126400 / 100;
- if( -x "/usr/sbin/setquota" )
+ if( -x "/usr/bin/quota" )
{
- #FIXME FIX QUOTA
- #COMPUTE $quota , its the used quota
+ open( CMD , "/usr/bin/quota -g ".$group->get_gid." |" );
- $group->get_quota_used( $quota );
+ while( $line = <CMD> )
+ {
+ if( $line =~ /^\s+.+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d*)/ )
+ {
+ ($bu) = ( $line =~ /^\s+.+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d*)/ );
+ }
+ }
+ close CMD;
- if( $group->commit < 0 )
+ if( defined( $bu ) && ( $bu > 0 ) )
{
- Vhffs::Robots::vhffs_log( sprintf( "Update quota for group %s set %s" , $group->get_groupname , $group->get_quota ) );
- Vhffs::Robots::vhffs_log( sprintf( "Update quota used for group %s " , $group->get_groupname ) );
+ $su = $bu * 1024;
+ $su /= 1024;
+ $su /= 1024;
+
+ if( $su =~ /\./ )
+ {
+ ( $su ) = ( $su =~ /(\d+)\./ );
+ }
+ $group->set_quota_used( $su );
+
+ if( $group->commit > 0 )
+ {
+ Vhffs::Robots::vhffs_log( sprintf( "Update quota used for group %s set %s" , $group->get_groupname , $su ) );
+ Vhffs::Robots::vhffs_log( sprintf( "Update quota used for group %s " , $group->get_groupname ) );
+ }
}
+ }
+ else
+ {
+ Vhffs::Robots::vhffs_log( "Error, quota command not found" );
}
}
}