Comments (28)
Windows xp machine fails:
1> Pid usage should get pid usage:
Uncaught AssertionError: expected [Error:
Fri Apr 28 2017 08:02:13 GMT+0100 Wmic errored, please open an issue on https://github.com/soyuka/pidusage with this message.
Command was "wmic PROCESS 3708 get workingsetsize,usermodetime,kernelmodetime"
System informations:
- release: 5.1.2600
- type: Windows_NT
Wmic reported no errors .
Stdout was empty] to be null
at C:<project>\node_modules\pidusage\test\test.js:47:24
at ChildProcess. <C:<project>\node_modules\pidusage\lib\stats.js:155:16>
at maybeClose <internal/child_process.js:829:16>
at Socket. <internal/child_process.js:319:11>
at Pipe._onclose net.js:486:12
Windows 7 machine all test passed.
from pidusage.
May I ask what is you windows version?
I wonder if the path has something do to with those lingering programs?
Yes it might, because we have to avoid spawning cmd.exe windows, we have to launch wmic.exe
in a detached mode. That said, if your own version of wmic
is failing (eg not exiting) or loops in the background, pidusage has no clue that it's not responding.
Can you try launching the command manually? If you have any idea on how to improve windows process usage/memory detection, I'm all ears!
from pidusage.
Hi, I am using win7 x64 sp1. But I think it might be pirated.
I have tried to lauch wmic path Win32_PerfFormattedData_PerfProc_Process WHERE IDProcess=xxxx get PercentProcessorTime, WorkingSet
and it gets stuck. But it returns immediately if I use wmic PROCESS 6968 get workingsetsize
from pidusage.
Hmm, might be that I had a similar problem but I found no fix to my issue... Check #16.
Thing is, I have no way to check that wmic path Win32_PerfFormattedData_PerfProc_Process WHERE IDProcess
works, nor can I send both commands to see which one works on the computer, or it'll eat a lot more ressources that it currently does.
I've looked at adding a windows binary in C#, but I don't know if it'll be as portable as wmic. Wmic should work on most windows versions > XP.
Let me know if I can do anything.
from pidusage.
That's okay, this is bound to happen when we have to rely on OS specific tools. I noticed that PM2 module uses this module to provide CPU and memory info, so I commented out that bit since that info is not crucial to me. Now PM2 does not get stuck any more. Thanks again for such prompt and detailed feedback. I am closing this issue for the moment.
from pidusage.
Can you tell what you commented out? I have the same issue...
from pidusage.
Can you try launching the command manually? If you have any idea on how to improve windows process usage/memory detection, I'm all ears!
from pidusage.
I'm afraid windows is not my weapon of choice, so I have no improvement ideas... but, sure I can call it manually, if you tell me how to figure out the process id needed in the line.
Btw. til now I was not able to comment out lines to make pm2 usable again, any idea how to disable wmic.exe usage?
from pidusage.
Sorry I was just quoting a previous reply of mine. Neither is windows my weapon of choice ;).
Process id can be found in the windows process manager or in the pm2 list or process.pid
global variable in node.
If you want to prevent wmic from running you can add this line here:
return done(null, {cpu : 0, memory : 0})
from pidusage.
Thanks for that line, seems to work now. I also run the command manually:
C:\Users\bbuser>wmic path Win32_PerfFormattedData_PerfProc_Process WHERE IDProcess=5424 get PercentProcessorTime, Workin
gSet
PercentProcessorTime WorkingSet
0 21262336
C:\Users\bbuser>
I took quite long, at least 3sec I would say and consumed 2 of 4 cores with 80%. Seems it should not be called in a short loop, other wise it starts many even before the first had finished. Probably that was at least one of the problems in my case, pm2 started more and more of it until the machine cried for a powercycle after a minute or so...
from pidusage.
Really interesting thx, I'll check that pm2 waits for a response before
issuing a new stat! Thx!
Le mer. 22 juin 2016 à 18:54, Thorsten Eggert [email protected] a
écrit :
Thanks for that line, seems to work now. I also run the command manually:
C:\Users\bbuser>wmic path Win32_PerfFormattedData_PerfProc_Process WHERE IDProcess=5424 get PercentProcessorTime, Workin
gSet
PercentProcessorTime WorkingSet
0 21262336C:\Users\bbuser>
I took quite long, at least 3sec I would say and consumed 2 of 4 cores
with 80%. Seems it should not be called in a short loop, other wise it
starts many even before the first had finished. Probably that was at least
one of the problems in my case, pm2 started more and more of it until the
machine cried for a powercycle after a minute or so...—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#19 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ABQr87oDw1cgMcCnamGgQIibI_8vnVa0ks5qOWisgaJpZM4IGFDD
.
from pidusage.
Sounds like a plan, perhaps you should even wait a sec or more (perhaps make it cfg able) after. As I said its not a lightweight call, and a update every sec should be good enough.
from pidusage.
It's waiting for the callback before issuing a new timeout: https://github.com/Unitech/pm2/blob/30239e142928ae04fa19733e186df4c9288f3949/lib/CLI.js#L1575. At least with pm2 monit
.
from pidusage.
Hi,
I believe I experience the same issue, which causes many WMIC.exe instance to be spanned, eating all CPU on the host.
I see the issue is marked as closed but wasn't able to see the solution.
In my case the host is Window Server 2012 R2.
PM2 version: 2.2.3
The problem is, once pm2 is up, almost every second a new WMIC.exe is spanned. For some time, these are cleaned up (exe terminates). However, after some time (i.e. some hours), WMIC.exe start piling up...
eventually they end up consuming CPU 100%. Server becomes almost dead.
Windows Event viewer shows more than 1000 errors for 10 minutes of WMI-Activity, all with the same error type.
https://www.screencast.com/t/8m1LaZe0u4
As a result, I had to disable keymetrics connection (pm2 interact delete), to avoid WMIC.exe usage.
I believe this issue blocks monitoring with pm2 on Windows hosts...
Regards.
from pidusage.
@erenayg wow this sucks!
I'll see if I can find a solution for you to keep monitoring (by reducing the number of calls to pidusage).
I've tried many many hacks and I believe that the current solution on pidusage can't get better (if I stick with wmic
). What I don't understand is why wmic is so process consuming...
nb error code: 0x80041033
Thanks for your report!
from pidusage.
It seems windows xp can't spawn the wmic process correctly which result in an unclosed wmic command prompt and will only return on.close results by killing it yourself.
Adding a space after 'wmic' in the spawn code fixed the problem for me.
lib/stats.js
spawn('wmic ', args.split(' '), {detached: true})
from pidusage.
Wow okay, do you know why? Have you access to another windows version to try if this hack also works there?
Thanks!!
from pidusage.
For some reason the wmic didn't hang on our windows 7 systems using pm2. I have added the space to the stats.js file to see if anything brakes but it seems to work ok on windows 7 as well.
from pidusage.
Okay thank you very much, I'll patch this asap!
from pidusage.
Solves a major problem for us, thx!
from pidusage.
I had to revert, unit tests are failing on appveyor :|. I'll see if I can get more informations
from pidusage.
Appveyor is apparently running on server R2, @yoyo497 I tried to add your fix only on older versions of windows, would you be able to run the test suite on windows xp?
git clone https://github.com/soyuka/pidusage
cd pidusage
npm install
npm test
from pidusage.
Hmm, so the space doesn't change anything but instead is breaking the command... I really wonder how you did make this work. My change goes as follow:
var wmic = spawn(releaseMajor < 6 ? 'wmic ' : 'wmic', args.split(' '), {detached: true})
So, it should apply the same fix as you...
from pidusage.
Yes i think your rigth. Im out of office till monday. I will do some more research why wmic wont close properly on windows xp.
from pidusage.
This would be greatly appreciated! Let me know if you need any information, I did a lot of digging on WMIC but the windows documentation is a mess!
from pidusage.
Problem fixed on xp adding this line:
wmic.stdin.end();
All test pass now :)
from pidusage.
Would you mind opening a pull request with your fixes? Thanks!
from pidusage.
thanks to @yoyo497 this should be resolved, feel free to ping if not.
from pidusage.
Related Issues (20)
- vscode-windows-process-tree integration
- Webpack fails to include platform methods HOT 1
- Linux is not supported yet README shows it as supported? HOT 1
- Ton of process open to check pidusage HOT 1
- pm2 app keeps stopping HOT 1
- add `command` property to output object
- Get ports occupied by certain process. HOT 1
- getting this error but is working in the another direcotry
- [BUG] pidusage not compatible with bundling due to dynamic requires in stats.js
- Not supported on IBM i ("os400") HOT 4
- Lost 3.0.1 Tag
- pnpm install pidusage 3.0.1 has ERR_PNPM_FETCH_404 problem
- uptime raises unhandled exception if current user has not sufficient privileges with node.js 16.18.0 and newer
- cpu value returns zero HOT 3
- openbsd support? HOT 1
- PM2 warn: [pidusage] We couldn't find uptime from /proc/uptime, using os.uptime() value HOT 1
- `pidusage` doesn't resolve if `pids` array gets modified meanwhile `updateCpu()` gets called HOT 3
- Error pm2 log nodejs v20.11.1 HOT 1
- Python extension error in VS code HOT 1
- Python Extension: (pidusage) Error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pidusage.