设为首页 收藏本站
查看: 830|回复: 0

[经验分享] 分析IIS日志技巧,找出问题出在哪里

[复制链接]

尚未签到

发表于 2015-8-13 07:53:19 | 显示全部楼层 |阅读模式
现代战争,发现就是毁灭,排除故障,优化性能也是一样,只要能找到问题在哪里,基本上成功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

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-98159-1-1.html 上篇帖子: WCF服务的创建和发布到IIS 下篇帖子: IIS无法启动:发生意外错误0x8ffe2740的原因
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表