aboutsummaryrefslogtreecommitdiffstats
path: root/config/squid3/31/squid_log_parser.php
diff options
context:
space:
mode:
authorMarcello Coutinho <marcellocoutinho@gmail.com>2013-05-02 23:45:28 -0300
committerMarcello Coutinho <marcellocoutinho@gmail.com>2013-05-02 23:45:28 -0300
commit5dcdeaed65444e21d523c79158865e0354759d8a (patch)
tree959dedd432c6c81f589950e1421e8c7339824ebf /config/squid3/31/squid_log_parser.php
parent4d387f9d2736877936da684097db00d8b775c960 (diff)
downloadpfsense-packages-5dcdeaed65444e21d523c79158865e0354759d8a.tar.gz
pfsense-packages-5dcdeaed65444e21d523c79158865e0354759d8a.tar.bz2
pfsense-packages-5dcdeaed65444e21d523c79158865e0354759d8a.zip
squid3 - mv squid files from squid-reverse to squid3/31
Diffstat (limited to 'config/squid3/31/squid_log_parser.php')
-rwxr-xr-xconfig/squid3/31/squid_log_parser.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/config/squid3/31/squid_log_parser.php b/config/squid3/31/squid_log_parser.php
new file mode 100755
index 00000000..f6cd7de8
--- /dev/null
+++ b/config/squid3/31/squid_log_parser.php
@@ -0,0 +1,57 @@
+#!/usr/local/bin/php -q
+<?php
+/* ========================================================================== */
+/*
+ squid_log_parser.php
+ part of pfSense (http://www.pfSense.com)
+ Copyright (C) 2012 Marcello Coutinho
+ Copyright (C) 2012 Carlos Cesario - carloscesario@gmail.com
+ All rights reserved.
+ */
+/* ========================================================================== */
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+/* ========================================================================== */
+
+# ------------------------------------------------------------------------------
+# Simple Squid Log parser to rewrite line with date/time human readable
+# Usage: cat /var/squid/log/access.log | parser_squid_log.php
+# ------------------------------------------------------------------------------
+
+$logline = fopen("php://stdin", "r");
+while(!feof($logline)) {
+ $line = fgets($logline);
+ $line = rtrim($line);
+ if ($line != "") {
+ $fields = explode(' ', $line);
+ // Apply date format
+ $fields[0] = date("d.m.Y H:i:s",$fields[0]);
+ foreach($fields as $field) {
+ // Write the Squid log line with date/time human readable
+ echo "{$field} ";
+ }
+ echo "\n";
+ }
+}
+fclose($logline);
+?> \ No newline at end of file