- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: How much CPU time take a process?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2007 01:10 AM
тАО07-29-2007 01:10 AM
I use "ps -eo pcpu,pid,user,args " - and get 0.5% CPU usage for my process.
But in the same time "top" shows that the same process takes ~10% CPU!
Can someone point me so same explanation of this phenomen?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2007 04:54 AM
тАО07-29-2007 04:54 AM
Re: How much CPU time take a process?
The cpu percentage is computed (usr+sys)/elapsed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2007 07:05 AM
тАО07-29-2007 07:05 AM
Re: How much CPU time take a process?
# time -p ls -lrt /var/crash
real 24.65
user 0.16
sys 0.43
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2007 05:25 PM
тАО07-29-2007 05:25 PM
Re: How much CPU time take a process?
But I need to build a metric for Ganlgia for monitoring some long-running processes, so "time" cannot help me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2007 12:14 AM
тАО07-30-2007 12:14 AM
Solutionhttp://linux.derkeiler.com/Mailing-Lists/SuSE/2005-08/2084.html
Jean-Pierre Huc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2007 05:33 AM
тАО07-30-2007 05:33 AM
Re: How much CPU time take a process?
Most tools today (top, ps) are using the proc nodes for this. This is also similar on windows using for example task manager.
This issue was discussed in the latest Linux Journal.
The case you're mentioning here with the difference between top and ps (both uses the same data for showing you the load) is because both these programs need to take two samples while your app is running to calculate the cpu usage. As long as these samples were not the exact same samples (time+duration), your results will differ.
Hope this clears things up a bit.
Lars
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2007 05:51 PM
тАО07-30-2007 05:51 PM
Re: How much CPU time take a process?
>Using linux on the x86 architecture using >tools that uses the proc nodes to >determine the cpu usage will always give >you an estimate on what the cpu usage is, >
>and not an accurate answer.
I understand this, but we cannot get more accurate results without kernel hacks.
> As long as these samples were not the >exact same samples (time+duration), your >results will differ.
Make sense! But probably top & ps use different algorithms too?
Of course, I cannot say that my comparison is 100% accurate, but my Ganglia graphs "ps -opcpu" output ( once a minute) and in the same time I running "top" on my terminal - the difference is *5 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2007 07:32 PM
тАО07-30-2007 07:32 PM
Re: How much CPU time take a process?
If you do a ps -ax you get a TIME field where is shows how much time of the cpu each process have been running. Now, convert this into seconds, and collect this value every minute, and you'll be able to calculate for each minute.
If you want a higher detail level, you can also grab the actual values from /proc/
Now that you know how to calculate how many seconds per minute a process is running, I guess it shouldn't be a big deal to convert it into % ;-)
Lars