#!/bin/sh # Interface variables for grepping RSH="/usr/bin/rsh" GREP="/usr/bin/grep" AWK="/usr/bin/awk" SQUID_LOG="/var/log/squid/access.log" SQUID_EXT_LOG="/var/log/squid/access_external.log" local_if="re0" isp1_if="xl0" isp2_if="eth1" isp3_if="eth3" # grep time in Epoch format ttime=`$RSH 127.0.0.1 show ip accounting | $GREP "Accounting data saved" | $AWK '{print ($4)}'` # Move accounting to checkpoint $RSH 127.0.0.1 clear ip accounting >> /dev/null # Read accounting from checkpoint for local_if $RSH 127.0.0.1 show ip accounting checkpoint | $GREP $local_if | $AWK -v vtime=$ttime '{print (vtime".000",1,$2,"TCP_MISS/200",$4,"CONNECT",$1":"$5,"-","DIRECT/"$1,"-")}' >> $SQUID_LOG # Read accounting from checkpoint for isp1_if $RSH 127.0.0.1 show ip accounting checkpoint | $GREP $isp1_if | $AWK -v vtime=$ttime '{print (vtime".000",1,$2,"TCP_MISS/200",$4,"CONNECT",$1":"$5,"-","DIRECT/"$1,"-")}' >> $SQUID_EXT_LOG # Read accounting from checkpoint for isp2_if #$RSH 127.0.0.1 show ip accounting checkpoint | $GREP $isp2_if | $AWK -v vtime=$ttime '{print (vtime".000",1,$2,"TCP_MISS/200",$4,"CONNECT",$1":"$5,"-","DIRECT/"$1,"-")}' >> $SQUID_EXT_LOG # Read accounting from checkpoint for isp3_if #$RSH 127.0.0.1 show ip accounting checkpoint | $GREP $isp3_if | $AWK -v vtime=$ttime '{print (vtime".000",1,$2,"TCP_MISS/200",$4,"CONNECT",$1":"$5,"-","DIRECT/"$1,"-")}' >> $SQUID_EXT_LOG