вот надыбал скрипт, который тащит лимит, как я понимаю.
#!/bin/sh
#
# get_ad_user_limit.sh - gets user traffic limits from AD via "description" field
# and creates file for ban_users.pl script
#
# 1.Variables
LDPASEARCH="/usr/bin/ldapsearch"
LDAPSEARCHARGS="-P3 -LLL"
LDAPPASS=`cat /etc/squid/ldappass`
USERLIMITSFILE="/etc/squid/limit/limits"
# 2.LDAP lookup against our Active Directory
RESULT=$($LDPASEARCH $LDAPSEARCHARGS -x -b 'dc=ratm-energo,dc=local' -w $LDAPPASS
-H ldap://alfa.ratm-energo.local -D "proxyldap@ratm-energo.local"
'(&(objectclass=user)(memberOf=CN=Internet,OU=internet access,DC=ratm-energo,DC=local)(description=*))'
sAMAccountName description 2>&1)
# 3.Testing for successfull lookup
if [ $? -ne 0 ]
then
echo "$0: LDAP lookup error: $RESULT"
exit 10
fi
# 4. Main parse procedure
# Emptying user limits file before update it with new values
:>$USERLIMITSFILE
flag=0
for line in $RESULT
do
if [ "$line" == "description:" ]
then flag=1
fi
if [[ $flag -eq 2 ]]
then
# Testing for numeric "description"
if echo $line | grep -q -E '^[0-9]*$'
then limit=$line
else limit=0
fi
fi
if [[ $flag -eq 4 ]]
then
user=`echo $line | tr A-Z a-z`
echo $user $limit >> $USERLIMITSFILE
flag=0
fi
if [[ $flag -ne 0 ]]
then let "flag=$flag + 1"
fi
done
chmod 0640 $USERLIMITSFILE
exit 0
рядом в этой же папке файлик "limits"
в котором все логины и через пробел лимит.
в этой же папке ещё скрипт
#!/usr/bin/perl
#
# ban_users.pl --- obtain monthly traffic usage by squid users
# and ban them if limit exceeded
#
use Fcntl;
#########################
# Variables #
#########################
$reportdir="/var/www/stats/lightsquid/report";
$limits_config="/etc/squid/limit/limits";
$banned_users="/etc/squid/limit/overusers";
$kilobyte=1000;
# We need to get current year and month
$time = time();
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time);
$year = $year + 1900;
$mon++;
$mon = sprintf("%02d", $mon);
# gets list of directories with current month statistics
opendir(DIR, "$reportdir") || die "can't opendir $reportdir: $!";
@current_month_dirs = grep {/^($year)($mon)[0-9]{2}$/} readdir(DIR);
closedir(DIR);
# Count summ traffic for current month for each user
foreach $dir (@current_month_dirs) {
open(FILE,"$reportdir/$dir/.total") || die "can't open file $reportdir/$dir/.total: $!";
while(<FILE>) {
($user,$in,$count,$out) = split;
$in = $in/($kilobyte*$kilobyte);
if(($user ne "user:")&&($user ne "size:")) {
$monthly_stats{$user} += $in;
}
}
close(FILE);
}
# Get traffic limit for each user from config
open(FILE,"$limits_config") || die "can't open file $limits_config: $!";
while(<FILE>) {
next if /#/ ;
($user, $traffic_limit) = split;
$traffic_limit{$user} = $traffic_limit;
}
close(FILE);
# Find users who have traffic overusage
# and write they to squid configuration file
unlink $banned_users;
sysopen(FILE, "$banned_users", O_WRONLY | O_EXCL | O_CREAT, 0650) || die "can't open file $banned_users: $!";
foreach(keys %traffic_limit) {
if($traffic_limit{$_} == 0) {
print FILE "$_
";
next;
}
if($monthly_stats{$_} > $traffic_limit{$_}) {
print FILE "$_
";
}
}
close(FILE);
# Make proxy group owner of the target file
if (chown(0, 13, "$banned_users" ) == -1) {
print "Chown $banned_users file failure
";
}
# chmod it
if (chmod(0640, "$banned_users" ) == -1) {
print "Chown $banned_users file failure
";
}
# Make squid reload configuration
system("/etc/init.d/squid reload 1>/dev/null");
if ($? == -1) {
print "squid reload failure
"
как я понимаю, он блокирует юзеров превышевших лимит.
ещё там же есть файлик overusers, он пустой, я не понимаю зачем он ))
Пользователь решил продолжить мысль 05 Августа 2009, 06:23:14:
вот, нашёл,в overusers помещаются забаненые юзеры.