LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 02-27-2014, 07:09 AM   #1
astura
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Rep: Reputation: Disabled
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?
 
Old 02-27-2014, 08:52 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
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
 
Old 02-27-2014, 09:57 AM   #3
astura
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
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%
 
Old 02-27-2014, 10:15 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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.
 
Old 02-27-2014, 10:19 AM   #5
astura
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
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.
 
Old 02-27-2014, 10:31 AM   #6
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
"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.
 
Old 02-27-2014, 11:18 AM   #7
astura
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
I was trying to avoid creating a bash script lol, but I guess can´t be done. Thanks a lot.
 
Old 02-27-2014, 11:21 AM   #8
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
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.
 
Old 02-27-2014, 12:50 PM   #9
astura
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by szboardstretcher View Post
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.
 
Old 02-27-2014, 01:09 PM   #10
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
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.
 
Old 02-28-2014, 02:17 PM   #11
astura
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
to whom it might interest I´ve recompiled ps to my needs
 
Old 02-28-2014, 02:20 PM   #12
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
definitely. do you have it up on github or something?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration