PerformanceCounter extremely slow in connecting remote server

若如初见. 提交于 2019-12-13 15:22:07

问题


I try to use PerformanceCounter to monitor remote server information in a domain environment, like:

var counter = new PerformanceCounter("PhysicalDisk", "Disk Bytes/sec", "_Total", "REMOTE_SERVER");

there is only 1 line of code, running the above code will wait at least 50 seconds.

I tried to impersonate the admin etc, still same time.

I also tried with PowerShell get-counter, still more or less speed.

I tried with windows native Performance Monitoring Tool in computer management, connect to remote server, takes a few second only.

Any idea how to improve the connection speed?


回答1:


If you are monitoring your local computer, I've found if I try and monitor localhost I sometimes get 1 minute or greater waits when setting up my PerformanceCounter objects. If I instead use 127.0.0.1 it seems to help.

However, it still happens sometimes when monitoring remote machines. Will update if I find a solution, I believe there is an alternative library called PDH which I am about to look into.



来源:https://stackoverflow.com/questions/14743852/performancecounter-extremely-slow-in-connecting-remote-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!