Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU usage is always 0 #76

Closed
zhouhuirun2015 opened this issue Jul 29, 2018 · 8 comments
Closed

CPU usage is always 0 #76

zhouhuirun2015 opened this issue Jul 29, 2018 · 8 comments

Comments

@zhouhuirun2015
Copy link

image

@zhouhuirun2015
Copy link
Author

windows server 2016 x64 standard with GUI
E5-2630v4
16GB

@soyuka
Copy link
Owner

soyuka commented Jul 30, 2018

Can you try to execute:

wmic PROCESS where ProcessId=YOUR_PID get CreationDate,KernelModeTime,ParentProcessId,ProcessId,UserModeTime,WorkingSetSize

@zhouhuirun2015
Copy link
Author

The result is:
C:\Windows\system32>wmic PROCESS where ProcessId=5896 get CreationDate,KernelModeTime,ParentProcessId,ProcessId,UserModeTime,WorkingSetSize
CreationDate KernelModeTime ParentProcessId ProcessId UserModeTime WorkingSetSize
20180714110222.629168+480 5375468750 5060 5896 25893281250 59334656

I use win32 exe which I compiled to get child process cpu usage, but it seems that child_process exec function return wrong pid.If I exec the win32 exe in CMD, it return the right result.

Here is the win32 exe code:

CpuUsage.txt

@soyuka
Copy link
Owner

soyuka commented Jul 31, 2018

The result looks correct to me, maybe try to call the usage a couple of times, the measure should settle with time.
I like your C++ code though, maybe it's faster then wmic. If we could make this as a node binding for windows it'd be awesome.

@zhouhuirun2015
Copy link
Author

I call the cpuUsage every 10 secs, it always return 0.but the wmic exec result is right.So maybe the problem is child_process exec func return wrong pid?

@soyuka
Copy link
Owner

soyuka commented Jul 31, 2018

You could debug the where clause here. I don't have access to a windows machine (especially no 2016 server edition), therefore I'm not sure how I could be able to help you...

@soyuka soyuka closed this as completed Aug 31, 2018
@blamay
Copy link

blamay commented Mar 14, 2019

I'm also experiencing this issue. It used to work, or at least for some of the PIDs, but it suddenly stopped working for all of them. Currently trying get it back to semi-working again to see if I can find a repro case.

EDIT: My solution was to check for cpu == 0 and retry until it showed correctly. It seems to happen every time at the beginning after the processes are first started.

@zarda
Copy link
Contributor

zarda commented Apr 3, 2019

My OS is ubuntu, the cpu usage still be 0 after a long time. ctime is very small, which is less than 1 ms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants