Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-27-2014, 07:09 AM
|
#1
|
LQ Newbie
Registered: Sep 2012
Posts: 10
Rep: 
|
better ps
Hey, I´ve done some research but was unable to find a program or a solution for my need.
I wanted to have a better output from ps, with more precision from the memory and cpu percentage processes are consuming, any tips?
|
|
|
02-27-2014, 08:52 AM
|
#2
|
LQ Guru
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465
Rep: 
|
Try typing "man ps" in a terminal and you'll see a bunch of options that may be what you're looking for. Your question is a bit vague so it's hard to know if this helps.
jdk
|
|
|
02-27-2014, 09:57 AM
|
#3
|
LQ Newbie
Registered: Sep 2012
Posts: 10
Original Poster
Rep: 
|
I´ve done that, the thing is, 0.0% for mem or cpu consumed is to "unprecise" for what I need, I wanted something like 0.00x%
|
|
|
02-27-2014, 10:15 AM
|
#4
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,795
|
Can you tell with more details what statistics you would like to be displayed and with which precision. Note that ps cpu values are not that useful, not being the percentage of anything sensible.
|
|
|
02-27-2014, 10:19 AM
|
#5
|
LQ Newbie
Registered: Sep 2012
Posts: 10
Original Poster
Rep: 
|
Well, what I want, the best precision CPU and Memory usage from processes, it would be better if they were even summed up if they are similar similar processes, something as "fast" as ps, it could even be absolute values, not necessarily percentage values.
smem is an alternative in memory usage part, but if there was tool that united both cpu and mem it would be best.
|
|
|
02-27-2014, 10:31 AM
|
#6
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,795
|
"ps" doesn't report the real CPU usage in the first place, "top", "htop" and similar are doing a better job here.
In any case, all of these tools are getting the kernel statistics by retrieving various /proc pseudo files. It should be easy to display any of the statistics you want with absolute values with a small shell script.
|
|
|
02-27-2014, 11:18 AM
|
#7
|
LQ Newbie
Registered: Sep 2012
Posts: 10
Original Poster
Rep: 
|
I was trying to avoid creating a bash script lol, but I guess can´t be done. Thanks a lot.
|
|
|
02-27-2014, 11:21 AM
|
#8
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
Well, hold on a second now.
Quote:
better output from ps, with more precision from the memory and cpu percentage processes are consuming
|
What exactly are you saying that you want?
Do you want the output to be different? If so, just show us the output you are concerned with, and an example of how you want it to look. No need to make a script to do a little bit of data manipulation.
|
|
|
02-27-2014, 12:50 PM
|
#9
|
LQ Newbie
Registered: Sep 2012
Posts: 10
Original Poster
Rep: 
|
Quote:
Originally Posted by szboardstretcher
Well, hold on a second now.
What exactly are you saying that you want?
Do you want the output to be different? If so, just show us the output you are concerned with, and an example of how you want it to look. No need to make a script to do a little bit of data manipulation.
|
I´ve once written this:
ps -eo pcpu,pmem,args --sort=args | grep -v "0.0[ ]*0.0" | awk '{print $1";;"$2";;"$3" "$4" "$5" "$6" "$7" "$8" "$9" "$10" "$11}' | awk -F";;" 'NR==1 {print $1" "$2" "$3} NR!=1 {cpu[$3]+=$1;mem[$3]+=$2}END{for(i in mem){print cpu[i]"\t"mem[i]"\t"i}}'
So I could get all processes "worth" mentioning that were indeed consuming resources, even putting same named processes together, but I thought that perhaps the precision 0.0% wasn´t good enough, so I wanted something like 0.000%, got it now?
Last edited by astura; 02-27-2014 at 01:10 PM.
|
|
|
02-27-2014, 01:09 PM
|
#10
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
Ahh. ok.
Well, you can pull out the numbers from /proc/, they are mostly integers that you will have to do a few readings on to get the deltas, then you can spit out a float of any precision.
fyi, cpu stats are in /proc/stat
but for me, knowing that 99.1 percent of my cpu's are being used is quite enough information for me. I dont see any benefit in knowing that it is 99.138928 percent.
edit: figure i better add some documentation on the /proc/stat file:
http://www.linuxhowtos.org/System/procstat.htm
Last edited by szboardstretcher; 02-27-2014 at 01:13 PM.
|
|
|
02-28-2014, 02:17 PM
|
#11
|
LQ Newbie
Registered: Sep 2012
Posts: 10
Original Poster
Rep: 
|
to whom it might interest I´ve recompiled ps to my needs
|
|
|
02-28-2014, 02:20 PM
|
#12
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
definitely. do you have it up on github or something?
|
|
|
All times are GMT -5. The time now is 04:20 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|