sp_monitor (Transact-SQL)
適用於:SQL Server
顯示 SQL Server Microsoft的相關統計數據。
Syntax
sp_monitor
傳回碼值
0 (成功) 或 1 (失敗)
結果集
資料行名稱 | 描述 |
---|---|
last_run | 上次執行時間 sp_monitor 。 |
current_run | 執行sp_monitor的時間。 |
seconds | 執行sp_monitor後經過的秒數。 |
cpu_busy | 伺服器電腦的 CPU 執行 SQL Server 工作的秒數。 |
io_busy | SQL Server 執行輸入和輸出作業所花費的秒數。 |
怠 | SQL Server 閑置的秒數。 |
packets_received | SQL Server 讀取的輸入封包數目。 |
packets_sent | SQL Server 所寫入的輸出封包數目。 |
packet_errors | 讀取和寫入封包時,SQL Server 所遇到的錯誤數目。 |
total_read | SQL Server 讀取次數。 |
total_write | SQL Server 的寫入數目。 |
total_errors | 讀取和寫入時 SQL Server 所遇到的錯誤數目。 |
連線 | 登入或嘗試登入 SQL Server 的數目。 |
備註
SQL Server 會透過一系列函式來追蹤其已完成多少工作。 執行 sp_monitor 會顯示這些函式傳回的目前值,並顯示自上次執行程式后變更多少。
針對每個數據行,統計數據會以數位(number)-number% 或 number(number) 的形式列印。 第一個 數位 是指 SQL Server 重新啟動之後的秒數(適用於 cpu_busy、 io_busy和 閑置)或總數(適用於其他變數)。 括弧中的數位是指自上次執行sp_monitor之後的秒數或總數。 百分比是上次執行sp_monitor之後的時間百分比。 例如,如果報表顯示cpu_busy為 4250(215)-68%,則自 SQL Server 上次啟動後 CPU 已忙碌 4250 秒、上次執行sp_monitor后 215 秒,以及上次執行sp_monitor之後的總時間的 68%。
權限
需要 系統管理員 (sysadmin) 固定伺服器角色中的成員資格。
範例
下列範例會報告 SQL Server 忙碌程度的相關信息。
USE master
EXEC sp_monitor
以下為結果集。
last_run current_run seconds
----------- -------------------------- ---------
Mar 29 1998 11:55AM Apr 4 1998 2:22 PM 561
cpu_busy io_busy idle
--------------- --------- --------------
190(0)-0% 187(0)-0% 148(556)-99%
packets_received packets_sent packet_errors
---------------- ------------ -------------
16(1) 20(2) 0(0)
total_read total_write total_errors connections
----------- ----------- ------------- -----------
141(0) 54920(127) 0(0) 4(0)