dotnet-counters 可用來監控 .Net Core 的 Process,像是這邊筆者準備了一份簡單的程式想要觀察其 CPU 與 Memory 這些資源上的變化狀況。

1.png

將程式運行起來。

dotnet run

2.png

運行起來後可用 dotnet-trace 查詢 Process。

dotnet-trace ps

3.png

接著就可透過 dotnet-counters 監控指定 Process 的資源使用狀態。

dotnet-counters monitor –refresh-interval $refreshInterval -p $processId

像是這邊剛剛查閱到了 dotnet run 起了兩個 Process,我們可以帶入 Process Id 監控。

dotnet-counters monitor –refresh-interval 1 -p 35603

4.png

5.png

dotnet-counters monitor –refresh-interval 1 -p 35608

6.png

7.png

dotnet-counters 會將指定 Process 的資源使用狀況依照指定的時間更新,直至程式結束。

8.png

9.png

10.png

Link