#! /usr/bin/awk -f # GREP-SQUID-ACCESS - finds IP in Squid access logs in time range # Copyright (C) 2007 Matous Jan Fialka # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. # # You should have received a copy of the GNU General Public License along with # this program. If not, see . BEGIN { help = "args: from= to= find= totals=[0|1|2]"; if (ARGC == 1) { print help; totals = 0; exit(1); } if (! from) from = 0; if (! to) to = 9999999999; if (! find) find = "^.*$"; if (! totals) totals = 1; total = 0; } { if ((($1 > from) && ($1 < to)) && ($3 ~ find)) if (totals == 2) total++; else print total++ " " strftime("%c", $1) " " $0; } END { if (totals) print "TOTAL ACCESSES " total; }