Skip to content

Commit 5a18a6c

Browse files
committed
add option to disable log rotation
1 parent f5f248f commit 5a18a6c

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Usage
3030
```
3131
usage: squid2radius.py [-h] [-p RADIUS_ACCT_PORT]
3232
[--radius-nasid RADIUS_NASID] [--squid-path SQUID_PATH]
33-
[--exclude-pattern EXCLUDE_PATTERN]
33+
[--exclude-pattern EXCLUDE_PATTERN] [--no-rotation]
3434
logfile_path radius_server radius_secret
3535
```
3636

@@ -48,6 +48,10 @@ You should also read [SquidFaq/SquidLogs](http://wiki.squid-cache.org/SquidFaq/S
4848

4949
If for some reason you need to prevent usage information of certain user from being sent to the RADIUS server, there is an argument for that! Use `--exclude-pattern="(girl|boy)friend"` and squid2radius won't send usage of either your `girlfriend` or `boyfriend` to the RADIUS server.
5050

51+
### --no-rotation
52+
53+
By default squid2radius calls `squid -k rotate` to make squid rotate your log files right after we are done counting usage data, in order to ensure usage data accuracy by not counting any log lines more than once next time you run it. If this is troublesome in your setup, you can add `--no-rotation` argument to disable this behavior.
54+
5155
Note
5256
----
5357

squid2radius.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@
1111

1212

1313
parser = argparse.ArgumentParser(description='Analyze squid log by user ' \
14-
'and upload result to RADIUS serv')
14+
'and upload result to RADIUS ' \
15+
'server.')
1516
parser.add_argument('logfile_path', help='logfile to analyze')
1617
parser.add_argument('radius_server')
1718
parser.add_argument('radius_secret')
1819
parser.add_argument('-p', '--radius-acct-port', default='1813')
1920
parser.add_argument('--radius-nasid', default='squid')
2021
parser.add_argument('--squid-path', default='/usr/sbin/squid')
21-
parser.add_argument('--exclude-pattern', default='', help='do not send to ' \
22-
'server if ' \
23-
'username contains '\
24-
'this regexp')
22+
parser.add_argument('--exclude-pattern', help='do not send to server if ' \
23+
'username contains this regexp',
24+
default='')
25+
parser.add_argument('--no-rotation', help='do not rotate squid log files',
26+
action='store_true')
2527
args = parser.parse_args()
2628

2729

@@ -94,7 +96,7 @@
9496
sys.stdout.write(".\n")
9597
sys.stdout.flush()
9698

97-
98-
print "\nRotating squid log..."
99-
call([args.squid_path, "-k", "rotate"])
99+
if not args.no_rotation:
100+
print "\nRotating squid log..."
101+
call([args.squid_path, "-k", "rotate"])
100102

0 commit comments

Comments
 (0)