sp_monitor (Transact-SQL)

适用于:SQL Server

显示有关 Microsoft SQL Server 的统计信息。

Transact-SQL 语法约定

语法

  
sp_monitor  

返回代码值

0 (成功) 或 1 (失败)

结果集

列名 说明
last_run 上次运行sp_monitor的时间
current_run 运行时sp_monitor
运行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打印。 第一个 数字 是指自 SQL Server 重新启动以来的秒数(对于 cpu_busyio_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)

另请参阅

sp_who (Transact-SQL)
系统存储过程 (Transact-SQL)