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

Implement process CPU kernel/user times #32

Closed
giampaolo opened this issue May 23, 2014 · 10 comments
Closed

Implement process CPU kernel/user times #32

giampaolo opened this issue May 23, 2014 · 10 comments

Comments

@giampaolo
Copy link
Owner

From billiej...@gmail.com on March 07, 2009 04:15:18

Implement a method to determine the amount of time that a process has
executed in kernel/user mode.

Original issue: http://code.google.com/p/psutil/issues/detail?id=32

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 06, 2009 19:17:01

Implemented on Windows as r224 .
Since this is the first time I put hands on C code a review would be needed.

Status: Started

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 07, 2009 05:00:05

Implemented on Linux as r225 .

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 09, 2009 08:44:19

Implemented on FreeBSD as r238 . Note that get_cpu_percent() returns results different
from top/ps since we are calculating it from raw data rather than using the kernel's
"pctcpu" value used by top/ps. Not sure if this is better or worse in the long run,
it may be necessary in the future to implement a platform-specific get_cpu_percent()
for FreeBSD to return the value from pctcpu.

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 13, 2009 09:28:39

Well we've got a problem with this on OS X. To read this data you need task_for_pid()
which requires the user or application to be a member of the procmod group, or the
script must be run as root. 

The best we can do is raise AccessDenied appropriately but it means psutil simply
won't be able to get CPU (or memory) data for a process unless psutil is being
executed in a root context or at the very least, as a member of procmod group.

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 13, 2009 09:58:21

IMO, it would make sense implementing CPU times this way by raising AccessDenied when
necessary, closing out this issue as fixed and opening a new one as reminder in case
we discover a task_for_pid() replacement.

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 13, 2009 10:00:35

Documentation and docstrings should also be updated to reflect this behavior.

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 13, 2009 10:15:47

I wouldn't bother opening a new issue for it, there's nothing wrong with using the
appropriate OS system calls so we'll just treat it as a known issue and leave it at that.

In r255 I've removed get_cpu_times/create_time from the __str__() method and wrapped
cpu times in a try/except in the Process constructor to account for this. I have not
yet implemented the code into the OS X module but once I do the _psutil module should
be ready for it at least.

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 17, 2009 09:15:15

Labels: Progress-3in4

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 20, 2009 14:15:18

Implemented on OS X as r270 .
Closing out this one.

Status: Fixed
Labels: -Progress-3in4

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 03:46:36

Updated csets after the SVN -> Mercurial migration: r224 == revision 
74261592f147 r225 == revision e7ec84bc5f8e r238 == revision 1e121fde0c0e r255 == revision 134cd2857e1a r270 == revision de3eed0d4a28

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

No branches or pull requests

1 participant