分析IIS日志技巧,找出问题出在哪里

现代战争,发现就是毁灭,排除故障,优化性能也是一样,只要能找到问题在哪里,基本上成功90%了。
毁灭恒久远,发现永流传。。。
1,发现本拉登,难度90%
2,毁灭之,难度10%
1,警察搜集证据,难度90%
2,抓捕嫌疑犯,难度10%
我们学习和提高的要点也在于:发现自己的问题在哪里,解决的办法就有了。
把有限的精力,放在重要的事情上。
先做个分析日志的工具先。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Web;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private int Index = 0;

private void button1_Click(object sender, EventArgs e)
{
this.progressBar1.Maximum = 10000 * 100;

string sql = string.Format("insert {0} select ", t.Text.Trim());
for (int i = 0; i < 10; i++)
{
sql
+= "'{" + i + "}' as C" + (i + 1) + " ,";
}

sql
= sql.Remove(sql.Length - 1);
MessageBox.Show(sql);
string path = string.Format(@"F:\LogFiles\{0}.log", txtLogName.Text.Trim());
System.IO.StreamReader rd
= System.IO.File.OpenText(path);

while (!rd.EndOfStream)
{
string StrRead = rd.ReadLine();
string[] arr = StrRead.Split(' ');
string SQL = sql;
if (arr.Length >= 10)
{
SQL
= string.Format(SQL, arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9]);
//Console.WriteLine(SQL);

SqlHelper.ExecuteNonQuery(SqlHelper.Conn, CommandType.Text, SQL);
this.richTextBox1.Text = SQL;
if (this.progressBar1.Value < this.progressBar1.Maximum)
{
this.progressBar1.Value++;
}
}
Application.DoEvents();
}
rd.Close();

MessageBox.Show(
"完成");
}

}
}
需要检查的五种异常.以后按照这个套路来分析日志.
一,--单次耗时最长的,超过了10秒,调用次数超过500次的
select C3,MAX(Cast(C10 as int) ) 单次耗时最长的, COUNT(c3) 请求次数  from IISLog616New 
where C3 not like '%.%'
group by C3
having MAX(Cast(C10 as int) ) >10000  and COUNT(c3)>500
order by MAX(Cast(C10 as int)) desc
 
/xmlgenerator/promotion 100063 13664
/flashcallback 96252 25303
/Product/GetItemsByNick 42567 1990
/Product/GetItemsByNickNum 42070 650
/Product 36426 742
/Code/GetTemplates 21682 562
/AddToTag 19628 507
/ 19315 525
/Product/List 19204 726
/Product/GetCurrentCount 18675 11227

--累计耗时最长的,超过一小时机时的
select C3,sum(Cast(C10 as int))  累计耗时最长的 , COUNT(c3) 请求次数  from IISLog616New  where C3 not like '%.%'
group by C3 having sum(Cast(C10 as int))>60*60 and COUNT(c3)>500
order by sum(Cast(C10 as int))  desc
/flashcallback 17131469 26218
/xmlgenerator/promotion 8369076 14231
/Product/GetCurrentCount 3513591 11536
/Product/GetItemsByNick 1291611 2050
/Product 731072 759
/Product/GetItemsByNickNum 691629 662
/Product/List 390751 742
/ 299727 544
/AddToTag 286354 527
/Code/GetSellerPromotionListCount 199568 817
/Code/GetTemplates 158288 571
/Code/GenerateCodeNew 147481 613
/Callback 134397 506

--平均耗时最长的
select top 10 C3,avg(Cast(C10 as int)) 平均耗时最长的 , COUNT(c3) 请求次数
 from IISLog616New  where C3 not like '%.%'
group by  C3 
order by avg(Cast(C10 as int))  desc
/Product/Edit/45024930 11491 3
/Product/Edit/44820260 7348 2
/Product/Edit/45035566 6882 2
/Order/Index/45022573 6152 1
/Product/Edit/44477711 5153 4
/Product/Edit/45037789 5073 1
/Product/Edit/45015466 4341 1
/Product/Edit/44575382 3704 3
/Product/Delete/45001785 2758 3
/Content/UploadPicture/gyhxzcl/Promotion/44400451/1<img+src= 2181 1
--请求次数最多的,大于次的
select C3,COUNT(c3) 请求次数最多的  from IISLog616New
 where C3 not like '%.%'
 group by C3 having COUNT(c3)>500
 order by COUNT(c3) desc
/flashcallback 29978
/xmlgenerator/promotion 16630
/Product/GetCurrentCount 12142
/Product/GetItemsByNick 2196
/Code/GetSellerPromotionListCount 841
/Product 802
/Product/List 780
/Product/GetItemsByNickNum 700
/Code/GenerateCodeNew 635
/ 603
/AddToTag 603
/Code/GetTemplates 591
/Callback 550
/Product/Success 520
/Code/BatchCode 502
--每IP请求次数最多的,大于次的
--每IP请求次数最多的,大于次的
 select C6,MAX(C3) 每IP请求次数最多的,COUNT(c3) 次数  from IISLog616New
 where C3 not like '%.%' group by C6 having COUNT(c3)>500
  order by COUNT(c3) desc
123.126.50.74 /Product/SingleProductCode 2565
119.127.37.129 /Product/RunUpdateAllProduct 1312
125.120.132.108 /Product/Template 1213
119.129.156.234 /xmlgenerator/promotion 1180
115.192.208.250 /Product/TemplateGetData 923
58.62.65.234 /Product/Template 874
183.3.96.108 /Product/TuanUpAndDown 735
123.148.211.207 /Product/GetCurrentCount 729
60.191.141.239 /Content/UploadPicture/渚濇惌閰 570
117.26.221.17 /xmlgenerator/promotion 553
119.145.255.169 /xmlgenerator/promotion 510
123.157.154.130 /xmlgenerator/promotion 507
posted @ 2011-06-16 21:41  CSDN大笨狼  阅读(668)  评论(1编辑  收藏  举报