分享

squid access.log分析

 thy 2009-12-17

#!/bin/bash
read -p "Enter the ip (1-254) to monitor: " -t 10 ip
read -p "Enter the query (eq:.mp3 .wma) to monitor: " -t 10 query
if [ "$ip" -ge "0" -a "$ip" -le "254" -a "$query" = "" ]
then
    tail -f /var/log/squid/access.log |grep 192.168.1.${ip}|awk '{print $3 "\t" $4 "\t" $7}'
elif [ "$ip" = "" -a "$query" = "" ]
then
    tail -f /var/log/squid/access.log |awk '{print $3 "\t" $4 "\t" $5 "\t" $6 "\t" $7}'
   # tail -f /var/log/squid/access.log
elif [ "$ip" = "" -a "$query" != "" ]
then
    tail -f /var/log/squid/access.log |grep $query|awk '{print $3 "\t" $7}'
elif [ "$ip" -ge "0" -a "$ip" -le "254" -a "$query" != "" ]
then
    #grep "192.168.1.$ip" /var/log/squid/access.log |grep "$query" |awk '{print $3 "\t" $4 "\t" $7}'|more
    tail -f /var/log/squid/access.log|grep "192.168.1.$ip" |grep "$query" |awk '{print $3 "\t" $4 "\t" $7}'
elif [ "$ip" -gt "254" -a "$query" = "" ]
then
    echo "the '$ip' is too big"
elif [ "$ip" != "[0-9]" -a "$query" = "" ]
then
    echo "you input '$ip' is not number"
else
    echo "input error"
    #tail -f /var/log/squid/access.log |awk '{print $3 "\t" $4 "\t" $5 "\t" $6 "\t" $7}'
fi

 

针对自己需求进行更改

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多