[Samba] dfree command and quotas
Luís Filipe Lobo
ellobo at ipb.pt
Thu Jul 3 21:39:28 GMT 2003
Hi!
I am trying to tune my samba server in what regards reporting the free space
for each share. I use a filesystem with quotas, kernel 2.4.21 in a Debian
linux box with samba 3.0.0beta1-2.
I usually get the quota information through the command:
# quota some_user
Disk quotas for user some_user (uid userID):
Filesystem blocks quota limit grace files quota limit
grace
/dev/hda2 30284108 31000000 31000000 61701 0 0
In my smb.conf i added the "dfree command = /home/samba/scripts/dfree.pl %U",
so each time the free space information is requested from the smb clients the
command is run.
The dfree.pl is a perl script, wich consists of:
/* begin of perl script */
#!/usr/bin/perl
open(LOG,">>/tmp/df_usage.log"); # create a log file
$com = "quota ".$ARGV[0];
open (PIPE, $com." |");
while (<PIPE>) {
# $_ = " /dev/hda2 30284108 31000000 31000000 61752 0 0"
if (($device, $used, $quota, $limit, $quotaInodes, $limitIndodes) =
m/[ ]+([a-z0-9\/]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+([0-9]+)[
]+([0-9]+)[ ]+([0-9]+)/) {
print $used." ".($quota-$used)."\n";
}
print LOG "I am " . $ENV{USER} . "\n" . $_; # write the real result of
quota to the log file plus the USER env var
}
close(PIPE);
close(LOG);
/* end of perl script */
In the some_user case above the perl script when run from a common shell
returns:
# ./dfree.pl some_user
30284108 715892
Wich is the used space and the available space until quota is exceeded.
Altough the dfree.pl script returns uota information for some_user in a common
shell i get:
/* begin /tmp/df_usage.log */
I am root
Disk quotas for user some_user (uid <the_id>): none
I am root
Disk quotas for user some_user (uid <the_id>): none
I am root
Disk quotas for user some_user (uid <the_id>): none
I am root
Disk quotas for user some_user (uid <the_id>): none
...
/* end /tmp/df_usage.log */
... in the log file when the command is run by samba.
Is there any issue regarding shell scripts executed from the "dfree command" ?
Is there any other "less ridiculous" way of getting the wanted result ?
Thanks in advance,
Keep up the good work,
LL
More information about the samba
mailing list