Analyzing EZproxy logs with Python
We use EZproxy to provide off-campus users with access to subscription resources that require a campus-specific login. Every time a user visits an EZproxy-linked page (mostly by clicking on a link in our list of databaes), that activity is logged. The logs are broken up monthly as either complete (~1 GB for us) or abridged (~10 MB). The complete logs look something like this:
EZproxy log snippet example — click to enlarge
We can get pretty good usage stats from the individual database vendors, but with monthly logs like these, why not analyze them yourself? You could do this in Excel, but Python is much more flexible, and much faster, and also, I've already written the script for you. It very hackily analyzes on- vs. off-campus vs. in-library use, as well as student vs. faculty use.
Use it on the command line like so:
python ezp-analysis.py [directory to analyze] [desired output filename.csv]
The script will spit out a CSV that looks like this:
With which you can then do as you please.
- "Sessions" are different from "connections." Sessions are when someone logs into EZproxy and does several things; a connection is a single HTTP request. Sessions can only be tracked if they're off-campus, as they rely on a session ID. On-campus EZproxy use doesn't get a session ID and so can only be tracked with connections, which are less useful. On-campus use doesn't tell us anything about student vs. faculty use, for instance.
- Make sure to change the IP address specifications within the script. As it is, it counts "on campus" as IP addresses beginning with "10." and in-library as beginning with "10.11." or "10.12."
- This is a pretty hacky script. I make no guarantees as to the accuracy of this script. Go over it with a fine-toothed comb and make sure your output lines up with what you see in your other data sources.
- Please take a good look at the logs you're analyzing and familiarize yourself with them — otherwise you may get the wrong idea about the script's output!
- Things you could add to the script: analysis of SPUs; time/date patterns; ...
Preliminary findings at John Jay
Here's one output of the data I made, with the counts of on-campus, off-campus, and in-library connections pegged by month from July 2008 to preset, overlaid with lines of best fit:
Click for larger
Off-campus connection increase: Between 2008 and 2014, database use off-campus saw an increase of ballpark 20%. Meanwhile, on-campus use has stayed mostly the same, and library use has dropped by ballpark 15%, although I think I must not be including a big enough IP range, since we've seen higher gate counts since 2008. Hm.
Variance: As you can see by the squigglies in the wild ups and downs of the pale lines above, library resource use via EZproxy varies widely month to month. Extreme troughs are obviously when school is not in session. Compared to January, we usually get over 3x the use of library resources in November. The data follows the flow of the school year.
Students vs. faculty: When school is in session, EZproxy use is 90% students and 10% faculty. When school is not in session, those percentages pretty much flip around. (Graph not shown, but it's boring.) By the numbers, students do almost no research when class is not in session. Faculty are constantly doing research, sometimes doing more when class is not in session.
Data issues: The log for December 2012 is blank. Boo. Throws off some analyses.
If you have suggestions or questions about the script, please do leave a comment!