Transact-SQL 参考

sp_monitor

显示关于 Microsoft® SQL Server™ 的统计。

语法

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) 的格式输出。第一个数字是指重新启动 SQL Server 以来的秒数(对于 cpu_busyio_busyidle)或总数目(对于其它变量)。圆括号中的数字是指上次运行 sp_monitor 以来的秒数或总数目。百分比是自上次运行 sp_monitor 以来的时间百分比。例如,如果报告中 cpu_busy 显示为 4250(215)-68%,则自 SQL Server 上次启动以来,CPU 工作了 4250 秒;自上次运行 sp_monitor 以来,CPU 工作了 215 秒;自上次运行 sp_monitor 以来占总时间的 68%。

权限

执行权限默认赋予 sysadmin 固定服务器角色的成员。

示例

下面的示例报告有关 SQL Server 繁忙程度的信息。

USE master
EXEC sp_monitor

下面是结果集:

last_run current_run Seconds
------------------ -------------------- -------------
Mar 29 1998 11:55AM Apr 4 1993 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)


请参见

sp_who

系统存储过程

使用变量和参数