arunoda / node-usage

process usage lookup with nodejs
MIT License
389 stars 93 forks source link

result cpu null #1

Closed WuTheFWasThat closed 11 years ago

WuTheFWasThat commented 11 years ago

I have keephistory set to false, and the cpu is often returned as null (memory continues to work fine). Do you have an idea what is happening? I'm guessing this is because the history has been cleared so recently that the cpu hasn't been polled again. But I'm only querying a few times a second, and the behavior is sort of random (not very consistent).

arunoda commented 11 years ago

node-usage has been only tested on Ubuntu for right now. This uses underline /proc/[pid]/stat file on the linux. It's format is different from distro to distro.

Thanks.

arunoda commented 11 years ago

BTW: You should be getting NaN?

amol-kulkarni commented 11 years ago

There is a same issues.. The CPU is often returned as 'null'

WuTheFWasThat commented 11 years ago

Thanks for the reply!

1) CentOS 6.3

2) Here are some examples of the /proc/[pid]/stat contents:

190460 (octave) S 190455 190236 187640 34816 190236 4202496 5961 0 0 0 11 4 0 0 20 0 1 0 191802656 213696512 5771 18446744073709551615 4194304 4196692 140734148297568 140734148291000 139740445249024 0 0 268435456 1132560127 18446744071583900537 0 0 17 0 0 0 1 0 0 0 0 0 0 0 20882 101 101 101

190445 (octave) S 190440 190236 187640 34816 190236 4202496 6189 587 0 0 11 6 0 0 20 0 1 0 191785519 213692416 5770 18446744073709551615 4194304 4196692 140734512195488 140734512188920 140294344699392 0 0 268435456 1132560127 18446744071583900537 0 0 17 0 0 0 1 0 0 0 0 0 0 0 20875 101 101 101

(seems funny that they are so similar, no?)

arunoda commented 11 years ago

@amol-kulkarni can you please also provide following information?

arunoda commented 11 years ago

@WuTheFWasThat okay. I'll add centos support. Will work on this.

arunoda commented 11 years ago

I really can't find any issue with your /proc/[pid]/stat/ BTW: Can you please try the example in the example folder?

WuTheFWasThat commented 11 years ago

Yeah, I think perhaps it is NaN. Sorry if I confused by saying it was null. My logging is on the client side, so after it gets JSON stringified, it becomes null, I think.

I tried the example and it seems to work fine. But if you set the timeout lower, you start to see NaN. Is the explanation just that there is no history, then? If so, this isn't a big problem. Thanks again

arunoda commented 11 years ago

It should work fine if you set keepHistory=false. Try to keep the interval just above 1 sec. There is a possible fix for this (you can specify min history tracking interval), but I think I have some more important things to do :)

Patches are welcome!

On Thu, Mar 21, 2013 at 3:32 AM, Jeff Wu notifications@github.com wrote:

Yeah, I think perhaps it is NaN. Sorry if I confused by saying it was null. My logging is on the client side, so after it gets JSON stringified, it becomes null, I think.

I tried the example and it seems to work fine. But if you set the timeout lower, you start to see NaN. Is the explanation just that there is no history, then? If so, this isn't a big problem. Thanks again

— Reply to this email directly or view it on GitHubhttps://github.com/arunoda/node-usage/issues/1#issuecomment-15206612 .

Arunoda Susiripala

@arunoda http://twitter.com/arunoda http://gplus.to/arunodahttps://github.com/arunoda http://www.linkedin.com/in/arunoda

WuTheFWasThat commented 11 years ago

No problem. I have my ways of dealing with this as well. Definitely go work on those other things!

arunoda commented 11 years ago

Thanks.

On Thu, Mar 21, 2013 at 11:39 AM, Jeff Wu notifications@github.com wrote:

No problem. I have my ways of dealing with this as well. Definitely go work on those other things!

— Reply to this email directly or view it on GitHubhttps://github.com/arunoda/node-usage/issues/1#issuecomment-15221125 .

Arunoda Susiripala

@arunoda http://twitter.com/arunoda http://gplus.to/arunodahttps://github.com/arunoda http://www.linkedin.com/in/arunoda