使用 powershell 获得计数器性能
Posted
技术标签:
【中文标题】使用 powershell 获得计数器性能【英文标题】:Get counter performance with powershell 【发布时间】:2014-04-25 11:59:43 【问题描述】:我正在尝试获取有关 iis 请求的信息,但是当我尝试通过以下方式获取计数器性能时:
Get-WmiObject Win32_PerfRawData_ASP_ActiveServerPages
我收到以下错误:
Get-WmiObject : Invalid class
At line:1 char:21
+ $totob=Get-WmiObject <<<< Win32_PerfRawData_ASP_ActiveServerPages
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
【问题讨论】:
【参考方案1】:性能计数器库可能会损坏并且必须重新构建。
这篇知识库文章描述了重建计数器库的过程。
http://support.microsoft.com/kb/300956
【讨论】:
【参考方案2】:首先你在哪个系统上试验这个问题?
你可以试试:
Get-WMIObject -List| Where$_.name -match "^Win32_.*_ASP.*" | Sort Name | Format-Table name
这是我的 W2K8R2 服务器上的结果:
Win32_PerfFormattedData_ASP_ActiveServerPages
Win32_PerfFormattedData_ASPNET_ASPNET
Win32_PerfFormattedData_ASPNET_ASPNETApplications
Win32_PerfFormattedData_ASPNET2050727_ASPNETAppsv2050727
Win32_PerfFormattedData_ASPNET2050727_ASPNETv2050727
Win32_PerfFormattedData_ASPNET4030319_ASPNETAppsv4030319
Win32_PerfFormattedData_ASPNET4030319_ASPNETv4030319
Win32_PerfFormattedData_aspnetstate_ASPNETStateService
Win32_PerfRawData_ASP_ActiveServerPages
Win32_PerfRawData_ASPNET_ASPNET
Win32_PerfRawData_ASPNET_ASPNETApplications
Win32_PerfRawData_ASPNET2050727_ASPNETAppsv2050727
Win32_PerfRawData_ASPNET2050727_ASPNETv2050727
Win32_PerfRawData_ASPNET4030319_ASPNETAppsv4030319
Win32_PerfRawData_ASPNET4030319_ASPNETv4030319
Win32_PerfRawData_aspnetstate_ASPNETStateService
这是我的 Window 8 上的结果
Win32_PerfFormattedData_ASPNET_ASPNET
Win32_PerfFormattedData_ASPNET_ASPNETApplications
Win32_PerfFormattedData_ASPNET4030319_ASPNETAppsv4030319
Win32_PerfFormattedData_ASPNET4030319_ASPNETv4030319
Win32_PerfFormattedData_aspnetstate_ASPNETStateService
Win32_PerfRawData_ASPNET_ASPNET
Win32_PerfRawData_ASPNET_ASPNETApplications
Win32_PerfRawData_ASPNET4030319_ASPNETAppsv4030319
Win32_PerfRawData_ASPNET4030319_ASPNETv4030319
Win32_PerfRawData_aspnetstate_ASPNETStateService
服务 W3SVC 未运行的地方。
【讨论】:
我使用的是 windows server 2008 r2 标准,这就是我得到的:以上是关于使用 powershell 获得计数器性能的主要内容,如果未能解决你的问题,请参考以下文章
创建性能计数器 PowerShell:指定类别的计数器布局无效
如何使用Powershell脚本获取Azure VM来宾指标(性能计数器)