Author Topic: [HELP] limit internet usage  (Read 4475 times)

codedmind

  • Zen Monk
  • **
  • Posts: 54
  • Karma: +2/-0
    • View Profile
Re: [HELP] limit internet usage
« Reply #15 on: October 09, 2012, 03:46:23 pm »
I'm search info right know about squish... if result in anything i will post the result.

FarquahrWindsor

  • Guest
Re: [HELP] limit internet usage
« Reply #16 on: October 09, 2012, 04:00:02 pm »
codedmind stuartiannaylor@hotmail.com

I know we can collate the info from light squid and get day totals.

Then we need a setting somewhere which will have to be a conf file.
Zmoddev isn't released yet and that makes it so much easier to customise zentyal.

I am thing it wouldn't be hard to get either user or ip infomation if authorisation isn't done.
Still have problems for me if the computer has migrating users.

Thing I haven't worked out is how to stop internet access.

Give us a shout if you find anything as I will have a go at creating some hooks and customisation.
So far I have never done anything at this level and I don't think its as simple as christian makes it sound but maybe I am wrong.
Christian would you like to share infomation and maybe guide us to how this may be done?

If you want to go solo then thats ok codedmind but if you want to share the chore I will help as it would be very useful.

codedmind

  • Zen Monk
  • **
  • Posts: 54
  • Karma: +2/-0
    • View Profile
Re: [HELP] limit internet usage
« Reply #17 on: October 09, 2012, 04:04:02 pm »
I found this

http://www.sitepoint.com/forums/showthread.php?880373-how-to-set-bandwidth-quota-on-user-in-squid-server&s=ae27947dad80a5b3964a92a97266a306&p=5191974&viewfull=1#post5191974

They saying that work, per hour, day and mouth... i don't try it, but for know is the most promise info i found. The squish is dated from 2006... i will keep doing some more search... and if i can't found nothing i will try it then

christian

  • Guest
Re: [HELP] limit internet usage
« Reply #18 on: October 09, 2012, 04:11:50 pm »
 :o I never wrote this is or will be "that simple"  ::)  or did I somewhere  ??? ???

Anyway, for the time being, all initiatives to achieve that I'm aware of were dropped before being released. (I though Squish was not progressing since a while too)
Look at "quota squid", "squid quota"...
All are quite old and not deployed. Initiative in Squid community is not started yet although there is a general agreement that such need exists.

General idea is to develop something using redirector and then set ACL. Starting point is here (as posted already few steps before) but I can't help further as I'm definitely not Squid specialist, at least at development level.






FarquahrWindsor

  • Guest
Re: [HELP] limit internet usage
« Reply #19 on: October 10, 2012, 03:23:50 am »
Quote
Carrying on from my pants way I installed lightsquid.

I created a little script as I am running this once a minute. You will have to see what hit this takes
Just will not let it run until its finished

sudo crontab -e
*/1 * * * * /usr/share/lightsquid/run-lightparser

Quote
/usr/share/lightsquid/run-lightparser
#!/bin/bash
## envvar set to stop cron repeating before finish and running the script up its own ass
if [ "$LIGHTPARSEISRUNNING" == "" ];
then
echo "`date` LIGHTPARSEISRUNNING=$LIGHTPARSEISRUNNING" >> /var/log/syslog ##Remark command out after all is well
export LIGHTPARSEISRUNNING=TRUE
   perl /usr/share/lightsquid/lightparser.pl
export LIGHTPARSEISRUNNING=
fi

Quote
I did an
apt-get install lightsquid
Quote
, so I don't know how you installed your files might be in different places

Quote
anyway that does it stuff I wished it create just the files in total but it makes folders in
/var/lib/lightsquid/reports/YYYYMMDD format

Quote
In there you have individual files by ip address .overuser .realname .total

also this made me think does lightsquid keep making these files as /var is going to get full of these psuedo logs

anyway if you change logrotate for squid to a day then these should keep manageable and its up to the sysadmin when to clear.

I know this is a horrid method and I am a dirty horrid hacker but I have totals by the minute via ip

All I need now is to create a conf file in
/etc/lightsquid/limits.conf
Quote
that sets limits
Add to my initial script where it compares ip's bandwidth used to the above limits.conf and if over quota put them into a
/etc/lightsquid/restricted.conf

Quote
which becomes part of the squids authentication

acl restrictedusers proxy_auth "/etc/lightsquid/restricted.conf"

http_access deny restrictedusers

Quote
Then thats it done by ip

Now all I have to do is make some routine to use the last command and match up where users where and thats it done by user.

I will have another go and add later to the dirty horrid hackers guide, I did mean to be at user name stage so I haven't checked about auth by ip
« Last Edit: October 10, 2012, 03:33:30 am by FarquahrWindsor »

codedmind

  • Zen Monk
  • **
  • Posts: 54
  • Karma: +2/-0
    • View Profile
Re: [HELP] limit internet usage
« Reply #20 on: October 10, 2012, 09:54:15 am »
Sorry but i don't understand your post...

Is that a howto to solve the internet usage?

FarquahrWindsor

  • Guest
Re: [HELP] limit internet usage
« Reply #21 on: October 10, 2012, 11:53:49 am »
Well its me doing a couple of things really.

But using the totals from lightsquid and a compare to a conf file where maximums by creating a restricted.conf with the ips or users that are above the maximums for the day then yes it would actually work.

What is really needed is to stick squid logs in a sql-database as lightsquid is creating day totals in /var/lib/lightsquid/reports and use squid with mysql logging with a running total trigger and a compare. Would be much lighter and faster with a process hit not much more of creating each log-line.

Thing is because of the nature of the logs and scripts you can accomplish much with hacks but because of the many forms of authentication you can't be sure what you will get in the logs. Ip or username and also traffic that might bypass the proxy.

So I think I will end up with a SQL module but I have been waiting for the release of 3.0  and I am dusting off my programming skills which are M$ based and very rusty. We don't seem to have any community surrounding the fact with a couple of scripts you can accomplish much. So its also my dirty hacking guide to Zentyal that hopefully will get more refined and hopefully with community involvement someone will say that is bad do it this way.

So its a few things.

What I did find out is that there is a pam_script authentication module where hooks can be made on authentication. Whilst I trawled the Zentyal framework it all seems to provide hooks for configuration but little for operation. I am going to put pam_scipts into my wish list.

It wasn't really my choice it was just something Christian said about go and find it yourself and bring it to the community. I have been meaning to get back into devel mode so it spurred me into action. I am just going to document each attempt from initial dirty hacks to hopefully something more polished and proficient.
Hopefully others who are more skilled will add or provide guidance... That sort of thing.

christian

  • Guest
Re: [HELP] limit internet usage
« Reply #22 on: October 10, 2012, 12:35:40 pm »
Stuart,

I just said "such feature doesn't exist with Zentyal because it doesn't exist currently with Squid. All previous equivalent modules developed in the past are now "dead" and not maintained".

So if you're able to find to develop something, you're move than welcome bringing it to community. Even Squid community if it makes you comfortable  ;)l

FarquahrWindsor

  • Guest
Re: [HELP] limit internet usage
« Reply #23 on: October 10, 2012, 01:19:21 pm »

some Squid-add-on may exist to handle quota but not available, as far as I know, with Zentyal and I never used it.
If you find one fitting your needs, you can still test it and bring it to community  8)
Some hints:
http://sourceforge.net/apps/trac/squidquota/
http://wiki.squid-cache.org/Features/Quota  (notice the "not started" status  ;)

Yeah it was a good idea even though looking into the the squid usage limiting is more complex than I first thought.
I am sort of toying with the idea that the lightsquid reporting has much overlap with the collation of user quota's and I can bring in a mysql based version that looks like lightsquid for reporting and also have the ability to use the data collection for limiting.
« Last Edit: October 10, 2012, 01:22:18 pm by FarquahrWindsor »