You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
我现在遇到了一个问题,在使用HertzBeat中的采集器监控Windows Server性能指标时,发现每执行一条PowerShell命令就会占用大约5%的CPU,执行两条的话就会占用10%左右。进一步观察发现,频繁地创建和销毁PowerShell进程会导致CPU占用率居高不下。这个问题看起来挺严重的,特别是在需要长期监控的情况下,资源消耗可能会变得非常大,尤其对配置较低的服务器并不适用。
在模拟测试中发现每次执行命令都需要启动一个新的PowerShell进程,而这个进程的启动和销毁过程本身就比较耗资源。
接下来,应该考虑如何优化这个过程。首先想到的是,能否重用已经存在的PowerShell进程,而不是每次都创建新的进程。这样可以减少进程创建和销毁的开销,从而降低CPU的占用。比如,可以使用PowerShell的会话机制,保持一个长期的会话,多次执行命令,而不是每次都启动一个新的PowerShell。
Beta Was this translation helpful? Give feedback.
All reactions