Billing and restricting traffic are 2 different things..
You can do a simple time acl in squid (right from the docs):
acl USER1 proxy_auth Dick
acl USER2 proxy_auth Jane
acl DAY time 06:00-18:00
http_access allow USER1 DAY
http_access deny USER1
http_access allow USER2 !DAY
http_access deny USER2
or
acl FOO src 10.1.2.3 10.1.2.4
acl WORKING time MTWHF 08:30-17:30
http_access allow FOO WORKING
http_access deny FOO
but it's not too flexible , so for controlling access based on units of time, may I suggest squidGuard.. you can install it without interfering with a running squid too much - it is an add-on program for squid. squidGuard has exactly what you want if you need to control end user access based on time of day, hours per week/day. It will allow you to write rules for ACLs which you create, then rewrite URLs, redirect to a CGI, or silently drop, based on these rules - and you can create if/then/else for actions based on being "within" or "outside" of your time space ACL . All of it is detailed in the documentation, and the contrib section contains some handy Perl examples too - so squidGuard might be a fast solution to most of your problem.
If you really need to do billing, it'll be more work, not to mention hitting issues as pointed out by
zigdon, with regard to cached content.
tachyon's one-liner is awesome for getting the bytes used out of the squid log ( actually my 2.5.STABLE3 out of the box logs had a different field layout requiring minor changes to get the output ) but you'll have to take action based on that, and reading logs is always after the fact.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.