選單
GSS 技術部落格
在這個園地裡我們將從技術、專案管理、客戶對談面和大家分享我們多年的經驗,希望大家不管是喜歡或是有意見,都可以回饋給我們,讓我們有機會和大家對話並一起成長!
若有任何問題請來信:gss_crm@gss.com.tw
2 分鐘閱讀時間 (497 個字)

[Tool]利用 Microsoft Monitoring Agent 來找出系統效能及異常問題

download-agent


想要蒐集系統有什麼異常或是效能問題嗎?
以前都是去解析IIS Log,現在您有更好的工具來幫忙哦!
原本在System Center中的Module,現在也可以單獨使用了哦!


最近公司有個系統,當系統中有比較多的資料時,一登入就會粉慢。

後來找到了「Introducing Microsoft Monitoring Agent」這篇文章。

於是下載「Microsoft Monitoring Agent 2013 」來試看看。

安裝完成之後,在服務之中會有 Microsoft Monitoring Agent 及 Microsoft Monitoring Agent APM ,如下,

image
 
然後就可以開始將較慢的網頁記錄下來,請以系統管理員身份開啟 PowerShell,

然後輸入 Start-WebApplicationMonitoring ,再來輸入要監看的 網站 及 監看的方式 ,如下,

image
 
註:如果一開始輸入時,發生如下的錯誤訊息,

image
無法辨識 'start-webapplicationmonitoring' 詞彙是否為 Cmdlet、函數、指令檔或可執行程式的名稱。請檢查名稱拼字是否正確,如
果包含路徑的話,請確認路徑是否正確,然後再試一次。
位於 行:1 字元:31
+ start-webapplicationmonitoring <<<<
+ CategoryInfo          : ObjectNotFound: (start-webapplicationmonitoring:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

請先Import module,如下,

import-module "C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\Microsoft.MonitoringAgent.PowerShell\Microsoft.MonitoringAgent.PowerShell.dll"
image
 
等測試完成後,就可以執行 Checkpoint-WebApplicationMonitoring 來建立 IntelliTrace 檔案,

或是執行 Stop-WebApplicationMonitoring "網站" 來停止監看並建立 IntelliTrace 檔案。

image
image
詳細 Cmdlet 使用方式,請參考 Cmdlet Reference
 
有了 IntelliTrace 檔案,我們就可以使用 Visual Studio Ultimate 2013 來開啟它,

可看到系統執行中的Exception,及效能較差的地方,如下,

image
 
效能的部份,還可以DBClick或是選擇後,按下「View Details」再看更詳細的資訊,如下,

image
image
image
如果有pdb,還可以進一步的Debug進去哦!

另外,分享最近遇到的一個案例,

Method 花費 176 ms,但全部花費卻高達 60 秒...


從60幾秒再往下去,居然只有 176 毫秒....

如上圖,Method A 從60幾秒再往下去看下去,居然只有 176 幾毫秒。

那時間到底花到那裡去了呢?

再看一下那個 176 毫秒的 Method ,原來它被包在 for ... next 之中,如下,


所以會花60幾秒,是因為 Run 了很多次那個 176 毫秒的Method哦!

所以下次看到類似的狀況,有可能是那個 Method 被 Run 了 很多次 哦!

註: 因為目前這版本用的是 VS 2013 的,所以請使用 Visual Studio Ultimate 2013 來查看比較順哦!

參考資料

從Developer來看 效能調校
Introducing Microsoft Monitoring Agent
Monitor apps in deployment with Microsoft Monitoring Agent
Monitoring Web Applications with Microsoft Monitoring Agent
Microsoft Monitoring Agent 2013
從【一例一休】牽拖以0.5小時為最小請假單位的作法
專案開動後,如何展開第一步的「差異分析」
 

評論

尚無評論
已經注冊了? 這裡登入
Guest
2024/05/06, 週一

Captcha 圖像