close

 

#統計squid Hit-rate

 


more /tmp/test


#!/bin/sh
awk '{print $5}' /var/log/squid3/access.log.1 | \
grep $1 | \
cut -d '/' -f 1 | \
sort | \
uniq -c

 

 

more /usr/local/sbin/Hit_Rate

#!/bin/sh
total=`wc -l /var/log/squid3/access.log.1 | awk '{print $1}'`
one=`/tmp/test TCP_HIT | awk '{print $1}'`
two=`/tmp/test TCP_MEM_HIT | awk '{print $1}'`
three=`/tmp/test TCP_IMS_HIT | awk '{print $1}'`
four=$((one+two+three))

x1=`echo $one / $total | bc -l | awk '{printf "%.3f",$0}'`
x1=`echo $x1 \* 100 | bc -l | awk '{printf "%.2f",$0}'`
x2=`echo $two / $total | bc -l | awk '{printf "%.3f",$0}'`
x2=`echo $x2 \* 100 | bc -l | awk '{printf "%.2f",$0}'`
x3=`echo $three / $total | bc -l | awk '{printf "%.3f",$0}'`
x3=`echo $x3 \* 100 | bc -l | awk '{printf "%.2f",$0}'`
x4=`echo $four / $total | bc -l | awk '{printf "%.3f",$0}'`
x4=`echo $x4 \* 100 | bc -l | awk '{printf "%.2f",$0}'`

printf `date +%F`"\t"$x1%%"\t\t"$x2%%"\t\t"$x3%%"\t\t"$x4%%"\n"

 

arrow
arrow
    全站熱搜

    slinbody 發表在 痞客邦 留言(0) 人氣()