Microsoft Monitoring Agent (MMA) 是可獨立運行的 IntelliTrace,可用來收集診斷資料,例如效能標準、事件記錄檔和Trace。

不像以前的 IntelliTrace 主要是綁在 Visual Studio 上使用,它能獨立運行,且功能也做了些許的強化,能與 System Center Operations Manager 做進ㄧ步的整合,提供更完善的Solution。

透過 Microsoft Monitoring Agent ,我們可以 Follow 編寫程式 => 建置 => 發佈 => 偵測 => 診斷 這樣的流程,不斷的進行迭代,讓產品更加的穩定。

Microsoft Monitoring Agent

Microsoft Monitoring Agent 主程式可至 Microsoft Monitoring Agent 2013 這邊下載安裝。

Microsoft Monitoring Agent

Microsoft Monitoring Agent

Microsoft Monitoring Agent

Microsoft Monitoring Agent

Microsoft Monitoring Agent

Microsoft Monitoring Agent

Microsoft Monitoring Agent

Microsoft Monitoring Agent

建議環境為 .NET Framework 3.5+、以及 PowerShell 3.0+。

在使用上,我們只要開啟 PowerShell ,輸入對應的命令就可以了。

若是使用的是 PowerShell 2.0,需先輸入下列命令去 Import module,不然會無法使用後續的 PowerShell Cmdlet。

Import-Module “C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\Microsoft.MonitoringAgent.PowerShell\Microsoft.MonitoringAgent.PowerShell.dll”

Microsoft Monitoring Agent

要開始啟用 Microsoft Montoring Agent 進行偵測,只要輸入命令:

Start-WebApplicationMonitoring

命令叫用的同時,會詢問要監測的網站 (即IIS上網站的名稱)、偵測的類型 (Monitor、Trace、Custom)、以及 Intellitrace 檔輸出的位置。

Microsoft Monitoring Agent

若想在當下立即產生 IntelliTrace 檔案進行分析,可叫用命令:

Checkpoint-WebApplicationMonitoring

Microsoft Monitoring Agent

若要終止偵測並將到目前為止的偵測儲存並產生 IntelliTrace 檔案,可叫用下列命令:

Stop-WebApplicationMonitoring [WebSite]

Microsoft Monitoring Agent

產生的 IntelliTrace file 可用 Visual Studio 開啟。

開啟後會看到像下面這樣的畫面,會顯示所偵測到的 Exception、 System Info 、以及 Module Info。

Microsoft Monitoring Agent

這邊通常我們關注的會是 Exception 這塊,找看看有沒有不該丟出的例外,找到後選取,在下方可看到對應的呼叫堆疊。

Microsoft Monitoring Agent

進一步要查閱的話,可滑鼠左鍵連點,或是按下 Start Debugging 按鈕,會進入到偵錯模式,可以看到細部的區域變數或是呼叫堆疊,若有 PDB 檔的這邊也可以將之 Attach 上去,看更細部的資訊。

Microsoft Monitoring Agent