A new tool has been in the works for generating summary information from BlueCoat proxy logs. The BlueCoat proxy log tool is designed to take compressed BlueCoat proxy logs and put relevant information into a mysql database where it generates the Top x number of users, source ip’s, websites, denied sites, the list of categories visited and total page views. It will accept 1 or more logs per run and the limits are hardware related only. You can take a look at the demo that is set up here at http://www.scripthat.com/log_report/. Currently the tool supports the “main” Bluecoat logs with the W3C Extended Log File Format (ELFF). The field construction also needs to be set up as follows…
gmtime c-ip cs-username cs-uri-scheme cs-host cs-uri-path cs-uri-query rs(Content-Type) s-action sc-filter-result sc-filter-category s-ip sr-bytes s-sitename r-port r-ip rs-bytes cs(User-Agent)
Other formats and field constructions can be set up in the future, and anyone wanting to help with the code is more than welcome. This is the first version of the tool, even though it runs smoothly for my purposes others may find some things that need improvement and may suggest features not yet implemented…your feedback is welcome.
The graphs are generated using Open Flash Charts, a great project That is located at http://teethgrinder.co.uk/open-flash-chart-2/ with continued improvement at http://www.openflashchart.com, it is LGPL licensed.
Below are the requirements and installation guidelines included in the readme:
Features
- Generates some graphs and statistics based on username, source ip address, Top websites, Top Denied websites, Top Categories and total page views.
- Can process one or more logs per run.
- Takes about 1 minutes to generate a report (depending on system) against a 15mb compressed (150mb uncompressed) file.
Takes 30 minutes to generate a report on 700mb compressed files (about 7gigs uncompressed) uses about 2gigs for database.
Requirements
Linux/Unix (Tested on Red Hat Enterprise 5 and Fedora Core 9)
Mysql (Tested on 5.0.77) you will need a version that supports InnoDB
Apache web server
Perl (Tested on v5.10.0) with the modules Date::Manip and DBI; perl -MCPAN -e “install Date::Manip”
PHP (Tested on v5.2.9)
Not required but very helpful — phpMyAdmin
Log file formatting
This tool is used for the “main” logs generated by BlueCoat proxy devices.
The format needs to be W3C Extended Log File Format (ELFF) with the string set as follows:
gmtime c-ip cs-username cs-uri-scheme cs-host cs-uri-path cs-uri-query rs(Content-Type) s-action sc-filter-result sc-filter-category s-ip sr-bytes s-sitename r-port r-ip rs-bytes cs(User-Agent)
Have the bluecoat ftp the file in compressed (.gz) format. This is what we use because it saves diskspace (and bandwidth).
A log file that would be 132 megs is 13.8 megs compressed so your logs use just about 10% of the diskspace.
Installation
Create a new database called proxy_reports
create a user who has full access to the database
create a password for the user
upload proxy_reports.sql.gz (easy using phpmyadmin) to build the tables needed.
Enable caching in mysql
Be sure to enable caching in mysql so the results from previous queries will be stored. The
max_allowed_packet needs to be set larger as well so that the database inserts will work, otherwise
the 1 mb default will stop the database updates.
Open your mysql configuration file (for Red Hat it is located at /etc/my.cnf )
put the following lines in the config :
#################################################################
# Set up query caching for fast results (after it’s been cached)
query_cache_size = 268435456
query_cache_type=1
query_cache_limit=1048576
# Max allowed packet needs to be bigger as well
max_allowed_packet=16M
#################################################################
And restart the mysql service
/sbin/service mysqld restart
Copy log_report folder to your web directory (typically /var/www/html)
Change ownership of all php files to your webserver (typically apache)
cd log_report
chown apache *
point your web browser to webserver/log_report/config.php
Edit the mysql variables to use the username and password for your database
Change the log directory to where your logs will be stored
Change the home directory to the home location (typically /var/www/html/log_report)
To generate a report change directories to log_report/perl change permissions and run bluecoat_reports.pl script
cd /log_report/perl
chmod 755 *
./bluecoat_reports.pl


