+ -
当前位置:首页 → 问答吧 → 数量核对不上啊?我写错了么?(iisLog分析 用的LogParser,sql语句和Sqlserver差不多)

数量核对不上啊?我写错了么?(iisLog分析 用的LogParser,sql语句和Sqlserver差不多)

时间:2011-12-21

来源:互联网

ip总数->
SQL code

select COUNT(distinct c-ip) as GueCount from 'F:ex111001.log'


结果->1865

//蜘蛛的ip总数
SQL code

    select COUNT(distinct c-ip) as GueCount from 'F:ex111001.log' where cs(User-Agent) like 
'%baidu%' or cs(User-Agent) like '%Yahoo!+Slurp%' or cs(User-Agent) like '%google%' or cs(User-Agent) like '%
YoudaoBot%' or cs(User-Agent) like '%sogou%' or cs(User-Agent) like '%msnbot%' or cs(User-Agent) like '%
+bingbot%'


结果->569

访客ip总量(代码和蜘蛛总量相似,只是将蜘蛛ip总量的sql语句中like前面加个not,同时or改成and),如下:
SQL code

select COUNT(distinct c-ip) as GueCount from 'F:ex111001.log' where cs(User-Agent) not like '%baidu%' and cs(User-Agent) not like '%Yahoo!+Slurp%' and cs(User-Agent) not like '%google%' and cs(User
-Agent) not like '%YoudaoBot%' and cs(User-Agent) not like '%sogou%' and cs(User-Agent) not like '%msnbot%' and cs(User-Agent) not like '%+bingbot%'


  结果->1304

问题来了,按道理结果应该是 ->【ip总量】 减掉 【蜘蛛的ip总量】,也就是1865-569=1296但是结果却是1304,怎么多出了8个?哪来的?希望高手帮忙想想...

作者: ximomomoxinei15   发布时间: 2011-12-21

完成代码(未整理..有点乱 但能看明白)->
C# code

           LogQuery oLogQuery = new LogQuery();
            IISInputFormat oIISInputFormat = new IISInputFormat();
            DateTime dt1 = DateTime.Now;
            //ip总量 1865(包括蜘蛛)
            //string query = @"select COUNT(distinct c-ip) as GueCount from 'F:ex111001.log'";
            
            //蜘蛛的ip个数
            //string query = @"select COUNT(distinct c-ip) as GueCount from 'F:ex111001.log' where cs(User-Agent) like '%baidu%' or cs(User-Agent) like '%Yahoo!+Slurp%' or cs(User-Agent) like '%google%' or cs(User-Agent) like '%YoudaoBot%' or cs(User-Agent) like '%sogou%' or cs(User-Agent) like '%msnbot%' or cs(User-Agent) like '%+bingbot%'";

            //百度
            string query = @"select COUNT(distinct c-ip) as GueCount from 'F:ex111001.log' where cs(User-Agent) not like '%baidu%' and cs(User-Agent) not like '%Yahoo!+Slurp%' and cs(User-Agent) not like '%google%' and cs(User-Agent) not like '%YoudaoBot%' and cs(User-Agent) not like '%sogou%' and cs(User-Agent) not like '%msnbot%' and cs(User-Agent) not like '%+bingbot%'";
            LogRecordSet oRecordSet = oLogQuery.Execute(query, oIISInputFormat);
           
            if (!oRecordSet.atEnd())
            {
                int guestCount = (int)oRecordSet.getRecord().getValue("GueCount");
                DateTime dt2 = DateTime.Now;
                //MessageBox.Show("访客总量->" + guestCount + "    |耗时" + (dt2 - dt1).ToString(),"提示");
            }
            oRecordSet.close();

作者: ximomomoxinei15   发布时间: 2011-12-21

怎么木人?

作者: ximomomoxinei   发布时间: 2011-12-21

1304 应该是准确的

like or 可能会导致统计出错

作者: Sandy945   发布时间: 2011-12-21

相关阅读 更多

热门下载

更多