I was intently used prstat Unix command on Sun Solaris trying to gather the information of number of the threads per process trying to audit the software fired threads per request to perform an action (need to skip details of the project).
That is just small helper that does the same on Linux
ps -o nlwp -p 7447
In addition, you might want (sorry, habits) to look for a Linux equivalent to Sun Solaris prstat -a command, that returns something like that:
NPROC USERNAME SWAP RSS MEMORY TIME CPU 24 root 211M 218M 2.7% 65:36:22 0.1% 3 azarutin 6672K 13M 0.2% 0:00:00 0.0% 1 abcd 4312K 7664K 0.1% 0:00:19 0.0% 1 nagios 496K 4440K 0.1% 0:16:31 0.0% 7 daemon 8840K 9832K 0.1% 0:20:18 0.0%<
The following Perl code does almost the same:
#!/usr/bin/env perl my @ps = `/bin/ps aux`; my @headers = split(/\s+/, shift(@ps)); my %users; foreach (@ps) { chomp; my $col = 0; my %ps_entry; foreach (split(/\s+/, $_, $#headers + 1)) { $ps_entry{$headers[$col]} = $_; $col++; } next unless exists $ps_entry{USER}; $users{$ps_entry{USER}} = { nproc=>0, size=>0, rss=>0, mem=>0, time=>0, cpu=>0 } unless exists $users{$ps_entry{USER}}; my $user = $users{$ps_entry{USER}}; $user->{nproc}++; $user->{size} += $ps_entry{VSZ} if exists $ps_entry{VSZ}; $user->{rss} += $ps_entry{RSS} if exists $ps_entry{RSS}; $user->{mem} += $ps_entry{'%MEM'} if exists $ps_entry{'%MEM'}; $user->{cpu} += $ps_entry{'%CPU'} if exists $ps_entry{'%CPU'}; $user->{time} += ($1 * 60) + $2 if (exists $ps_entry{'TIME'} && $ps_entry{'TIME'} =~ /^([0-9]+):([0-9]+)$/); } print "NPROC\tUSER\tSIZE\tRSS\tMEMORY\tTIME\tCPU\n"; foreach (sort { $users{$b}{cpu} <=> $users{$a}{cpu} } keys(%users)) { printf("%d\t%s\t%d\t%d\t%.1f\%\t%.2d:%.2d\t%.1f\%\n", $users{$_}{nproc}, $_, $users{$_}{size}, $users{$_}{rss}, $users{$_}{mem}, ($users{$_}{time} / 60), ($users{$_}{time} % 60), $users{$_}{cpu}); }
and returns the following result:
[azarutin@hope server]$ ./prstat.pl NPROC USER SIZE RSS MEMORY TIME CPU 62 azarutin 3955900 2308224 41.1% 82:07 1.1% 1 ntp 4420 4416 0.0% 00:00 0.0% 1 rpc 1924 524 0.0% 00:00 0.0% 1 smmsp 8300 1516 0.0% 00:00 0.0% 1 ricci 8288 1048 0.0% 00:00 0.0% 3 68 10596 3016 0.0% 00:10 0.0% 1 nobody 1932 432 0.0% 00:00 0.0% 1 dbus 3320 1332 0.0% 00:10 0.0% 1 rpcuser 2084 840 0.0% 00:00 0.0% 1 mysql 135408 23004 0.4% 00:01 0.0% 1 xfs 4360 2244 0.0% 00:01 0.0% 117 root 681476 101284 0.8% 21:31 0.0% 2 avahi 6456 1672 0.0% 00:41 0.0%
Enjoy !!!
Glad to visit this blog, keep it going.
Your website is actually great. Keep posting that way.
Cool blog!
You really make it seem so easy with your presentation but I find this matter to be really something that I think I would never understand. It seems too complicated and extremely broad for me. I’m looking forward for your next post, I’ll try to get the hang of it!
I am glad to be a visitant of this thoroughgoing site, thank you for this rare info!
Thank you for this postings and for your resource on the whole. I’ve just bookmarked it.
Ive been meaning to read this and just never received a chance. Its an issue that Im extremely interested in, I just started reading and Im glad I did. Youre a good blogger, one of the best that Ive seen. This blog certainly has some info on topic that I just wasnt aware of. Thanks for bringing this things to light.
How about the Linux eqvt for Solaris’ :
prstat -L -p
thx!
Good idea. Need to test it. Thanks.
I simply want to tell you that I’m new to blogs and actually enjoyed your web blog. Likely I’m want to bookmark your website . You amazingly come with perfect articles. Thanks a lot for sharing with us your web page.
You need to really control the commentary at this site
Nice to hear this. Thanks.