当前位置: 首页 > news >正文

Windows系统手动重新生成性能计数器

症状

使用性能监视器工具时,某些计数器可能缺失或不包含计数器数据。 性能计数器库可能已损坏,需要重新生成。

应用程序日志中可能会出现以下错误:

Log Name: Application  
Source: Microsoft-Windows-IIS-W3SVC-PerfCounters  
Event ID: 2002  
Level: Error  
Keywords: Classic  
Description:  
Setting up Web Service counters failed, please make sure your Web Service counters are registered correctly.
Log Name: Application  
Source: IISInfoCtrs  
Event ID: 1001  
Level: Error  
Keywords: Classic  
Description:  
Unable to read the first counter index value from the registry. The error code returned by the registry is data DWORD 0.

原因

如果某些可扩展计数器损坏注册表,或者 Windows Management Instrumentation (基于 WMI) 的程序修改注册表,则可能会发生此行为。

解决方案

若要解决此问题,请使用以下方法。

确保注册表中不会禁用计数器

可以通过注册表设置禁用计数器。 检查以下注册表位置,确保计数器未被禁用:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\%servicename%\Performance

 !备注

%servicename% 表示具有性能计数器的任何服务。 例如:PerfDisk、PerfOS 等。

这些位置中的任何一个都可能有 DisablePerformanceCounters 的注册表项。 根据 “禁用性能计数器”一文,此值应设置为 0。 如果该值是除 0 以外的任何值,则可能会禁用计数器。

  • 值为 1 表示已禁用计数器。
  • 值 2 表示禁用 32 位计数器。
  • 值为 4 表示禁用 64 位计数器。

重新生成所有性能计数器,包括可扩展计数器和第三方计数器

若要重新生成所有性能计数器,包括可扩展计数器和第三方计数器,请在管理命令提示符处键入以下命令。 在每个命令之后按 ENTER 。

  1. 重新生成计数器:

    cd c:\windows\system32
    lodctr /R
    cd c:\windows\sysWOW64
    lodctr /R
  2. 使用 Windows Management Instrumentation (WMI) 重新同步计数器:

    WINMGMT.EXE /RESYNCPERF
  3. 停止并重启性能日志和警报服务。

    Get-Service -Name "pla" | Restart-Service -Verbose
  4. 停止并重启 Windows Management Instrumentation 服务。

    Get-Service -Name "winmgmt" | Restart-Service -Force -Verbose
  5. 创建新的数据收集器集 (不使用现有的数据收集器集) 。

有时,运行 lodctr /R 可能不会恢复所有计数器。 如果注意到这种情况发生,请验证文件 c:\windows\system32\PerfStringBackup.INI 是否包含正确的信息。 可以从相同的计算机复制此文件以还原计数器。 从计算机到计算机,此文件可能略有不同。 但是,如果发现大小存在巨大差异,则可能缺少信息。 在替换之前,请始终创建备份副本。 不能保证从另一台计算机复制此文件将还原所有计数器。 如果可能,请将该文件与计算机的备份进行比较,以查看文件大小是否在某个时间点缩小。

对于许多计数器,要安装 perf 计数器的 ini 文件的位置位于下面 windows\winsxs,例如 IIS 的 ini 文件。

如果看到以下错误:

Log Name: Application  
Source: Microsoft-Windows-IIS-W3SVC-PerfCounters  
Event ID: 2002  
Level: Error  
Keywords: Classic  
Description:  
Setting up Web Service counters failed, please make sure your Web Service counters are registered correctly.
Log Name: Application  
Source: IISInfoCtrs  
Event ID: 1001  
Level: Error  
Keywords: Classic  
Description:  
Unable to read the first counter index value from the registry. The error code returned by the registry is data DWORD 0.

需要在目录 c:\Windows\winsxs中使用计数器安装 ini 文件。

需要修复的计数器可能存在多个文件夹。 在这些情况下,可能需要使用试用和错误来查找正确的 ini 文件。

例如,

Dir C:\Windows\winsxs\amd64_microsoft-windows-iis-metabase*

在此示例中,尝试使用以下方法从每个文件夹安装infoctrs.ini:

Lodtr infoctrs.ini

成功后,将在应用程序日志中看到以下条目:

Log Name: Application  
Source: Microsoft-Windows-LoadPerf  
Event ID: 1000  
Level: Information  
Description:  
Performance counters for the inetinfo (inetinfo) service were loaded successfully. The Record Data in the data section contains the new index values assigned to this service.

需要对以下计数器执行相同的操作:

amd64_microsoft-windows-iis-w3svc*

lodctr w3ctrs.ini

之后你将看到:

Log Name: Application  
Source: Microsoft-Windows-LoadPerf  
Event ID: 1000  
Level: Information  
Description:  
Performance counters for the W3SVC (World Wide Web Publishing Service) service were loaded successfully. The Record Data in the data section contains the new index values assigned to this service.

http://www.lryc.cn/news/155359.html

相关文章:

  • go elsaticsearch demo
  • 小游戏分发平台如何以技术拓流?
  • 力扣|找出和所对应的两数的下标
  • 使用命令行创建仓库
  • ESLint 中的“ space-before-function-paren ”相关报错及其解决方案
  • docker常用中间件安装
  • Camunda 7.x 系列【44】修改流程实例
  • 无频闪护眼灯哪个好?什么是无频闪
  • css网格布局
  • Hadoop -HDFS常用操作指令
  • 代码随想录二刷day11
  • 系统架构技能之设计模式-工厂模式
  • Docker的基本组成和安装
  • 【python爬虫】15.Scrapy框架实战(热门职位爬取)
  • Apinto 网关 V0.14 版本发布,6 大插件更新!
  • 突破销售瓶颈:亚马逊卖家如何借力TikTok网红营销?
  • JavaWeb之Cookie的简单使用!!!
  • 16、Flink 的table api与sql之连接外部系统: 读写外部系统的连接器和格式以及Apache Hive示例(6)
  • 6.Redis-hash
  • 点云从入门到精通技术详解100篇-多时相机载激光雷达人工林点云匹配及生长监测(续)
  • 【Vue3 知识第七讲】reactive、shallowReactive、toRef、toRefs 等系列方法应用与对比
  • Docker 摸门级简易手册
  • Java类加载机制
  • vue 自定义指令简单记录
  • 算法通关村-----快速排序的原理和实现
  • 百度抓取香港服务器抓取超时是什么情况?
  • Springboot上传文件
  • kafka教程
  • JVM的故事—— 内存分配策略
  • 21.CSS的动态圆形进度条