Monitor

% Process CPU Usage (specific process)

http://www.tek-tips.com/viewthread.cfm?qid=395765

for each Process in GetObject("winmgmts:{impersonationLevel=impersonate}//localhost").ExecQuery("Select PercentProcessorTime,IDProcess from Win32_PerfFormattedData_PerfProc_Process where IDProcess=4092")

WScript.Echo("================================")

For Each oProperty In Process.Properties_

WScript.stdout.write vbtab & oProperty.Name & "="

If IsArray(oProperty) Then

For iCount = 0 To UBound(oProperty)

WScript.stdout.write  oProperty.Value(iCount) & ","

Next

WScript.StdOut.WriteLine

ElseIf IsNull(oProperty) Then

WScript.stdout.writeline "Property not set"

Else

WScript.stdout.writeline oProperty.Value

End If

Next

WScript.Echo(Process.PercentProcessorTime)

WScript.quit

next
====================================================================================

for each Process in GetObject("winmgmts:").ExecQuery("Select * from Win32_Process")

WScript.echo Process.name & " " & CPUUSage(Process.Handle) & " %"

Next

Function CPUUSage( ProcID )

On Error Resume Next

Set objService = GetObject("Winmgmts:{impersonationlevel=impersonate}!\Root\Cimv2")

For Each objInstance1 in objService.ExecQuery("Select * from Win32_PerfRawData_PerfProc_Process where IDProcess = '" & ProcID & "'")

N1 = objInstance1.PercentProcessorTime

D1 = objInstance1.TimeStamp_Sys100NS

Exit For
 Next
 'WScript.Sleep(2000)
 
 For Each perf_instance2 in objService.ExecQuery("Select * from Win32_PerfRawData_PerfProc_Process where IDProcess = '" & ProcID & "'")

N2 = perf_instance2.PercentProcessorTime

D2 = perf_instance2.TimeStamp_Sys100NS

Exit For
 Next
 ' CounterType - PERF_100NSEC_TIMER_INV

' Formula - (1- ((N2 - N1) / (D2 - D1))) x 100

Nd = (N2 - N1)

Dd = (D2-D1)

PercentProcessorTime = ( (Nd/Dd))  * 100

CPUUSage = Round(PercentProcessorTime ,0)

End Function

WMI获取进程CPU占用率的更多相关文章

  1. 获取进程CPU占用率

    获取进程CPU占用率 // 时间转换 static __int64 file_time_2_utc(const FILETIME* ftime) { LARGE_INTEGER li; li.LowP ...

  2. docker运行容器后agetty进程cpu占用率100%

    1.最近在使用docker容器的时候,发现宿主机的agetty进程cpu占用率达到100% 在Google上搜了下,引起这个问题的原因是在使用"docker run"运行容器时使用 ...

  3. Linux下java进程CPU占用率高分析方法

    Linux下java进程CPU占用率高分析方法 在工作当中,肯定会遇到由代码所导致的高CPU耗用以及内存溢出的情况.这种情况发生时,我们怎么去找出原因并解决. 一般解决方法是通过top命令找出消耗资源 ...

  4. Linux下分析某个进程CPU占用率高的原因

      Linux下分析某个进程CPU占用率高的原因 通过top命令找出消耗资源高的线程id,利用strace命令查看该线程所有系统调用  1.top 查到占用cpu高的进程pid 2.查看该pid的线程 ...

  5. (转)Linux下java进程CPU占用率高-分析方法

    Linux下java进程CPU占用率高-分析方法 原文:http://itindex.net/detail/47420-linux-java-%E8%BF%9B%E7%A8%8B?utm_source ...

  6. Linux下java进程CPU占用率高分析方法(一)

    Linux下java进程CPU占用率高分析方法 在工作当中,肯定会遇到由代码所导致的高CPU耗用以及内存溢出的情况.这种情况发生时,我们怎么去找出原因并解决. 一般解决方法是通过top命令找出消耗资源 ...

  7. 2、获取APP CPU占用率

    前面已经介绍过如何获取包名和主活动名.这里不再过多赘述.我们依旧采取两种方案实现APP CPU占有率 Windows下获取APP CPU占用率 adb shell "dumpsys cpui ...

  8. Linux下java进程CPU占用率高-分析方法

    今天登陆同事的一台gateway 开始以为hive环境登陆不了了,仔细一看看了下是因为机器很卡,我每次等几秒没登陆就ctrl+c了,看了下是有个java进程cpu:340.4%  mem:14.6%  ...

  9. cidaemon.exe进程cpu占用率高及关闭cidaemon.exe进程方法

    问题描写叙述:   这段时间机器总是出现一个奇怪的问题:cidaemon.exe进程占用CUP率98%以上,大大影响了电脑的正常使用.资源管理器中出现多个cidaemon.exe进程,强制结束占用cp ...

随机推荐

  1. 改动Android设备信息,如改动手机型号为iPhone7黄金土豪版!

    首先你的手机必需要有ROOT权限,误操作有风险需慎重 请先开启手机的USB调试,防止手机改动后无法启动时导致的无法修复 1.假设你是在手机上改动,直接使用RE文件管理器,编辑/system/build ...

  2. BP神经网络模型及梯度下降法

    BP(Back Propagation)网络是1985年由Rumelhart和McCelland为首的科学家小组提出,是一种按误差逆传播算法训练的多层前馈网络,是目前应用最广泛的神经网络模型之一. B ...

  3. Find and counter

    Find: In a sense, find is the opposite of the [] operator. Instead of taking an index and extracting ...

  4. PostgreSQL 系统表

    postgres=# \d pg_class      Table "pg_catalog.pg_class"     Column     |   Type    | Modif ...

  5. c++几种排序算法代码

    #include <iostream> #include <vector> using namespace std; //交换int void swap(int& a, ...

  6. nginx的gizp压缩

    好处:         页面另存为大小比浏览器传输大小大很多.好处是加快传输.节省带宽.   原理:           浏览器 -> 请求 -> 声明可以接受的压缩方式[http 协议请 ...

  7. ArcGIS api for javascript——查询,然后单击显示信息窗口

    描述 本例展示如何配置查询任务为示例的工作流程: 1.用户单击一个要素来加亮显示. 2.用户再一次单击要素来查看属性信息的 InfoWindow. 本例查询USA州,因此ESRI_StateCityH ...

  8. Testin实验室:陌陌APP通过率为94.92% 基本满足移动社交需求

    Testin实验室:陌陌APP通过率为94.92% 基本满足移动社交需求 2014/11/10 · Testin · 独家评測 11月8日,国内移动社交应用陌陌公开向美国证券交易委员会提交了IPO申请 ...

  9. [React] Implement a React Context Provider

    If you have state that needs to exist throughout your application, then you may find yourself passin ...

  10. Use Uncertainty As a Driver

     Use Uncertainty As a Driver Kevlin Henney ConFRonTEd WiTH TWo opTionS, most people think that the ...