sp_monitor (Transact-SQL)

顯示有關 MicrosoftSQL Server 的統計資料。

主題連結圖示Transact-SQL 語法慣例

語法

sp_monitor

傳回碼值

0 (成功) 或 1 (失敗)

結果集

資料行名稱

描述

last_run

上次執行 sp_monitor 的時間。

current_run

執行 sp_monitor 的時間。

seconds

執行 sp_monitor 之後所經歷的秒數。

cpu_busy

伺服器電腦的 CPU 已執行 SQL Server 工作的秒數。

io_busy

SQL Server 已花在處理輸入和輸出作業的秒數。

idle

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 在讀取和寫入時所發現的錯誤數。

connections

登入或嘗試登入 SQL Server 的次數。

備註

SQL Server 會透過一系列的函數來持續追蹤它已完成的工作量。執行 sp_monitor 會顯示這些函數傳回的目前值,且會顯示自從上次執行這個程序之後,它們又有了多少改變。

每個資料行都會以 number(number)-number% 或是 number(number) 格式來列印統計資料。第一個 number 指 SQL Server 重新啟動之後的秒數 (針對 cpu_busyio_busyidle) 或總數 (針對其他變數)。括號中的 number 是上次執行 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)