How to write PHP script that gathers process resource usage data from the local system?

6 most memory-hungry processes – the 6 that are using the largest amount of RAM. i need to show the graph
vishnu kalakotaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan CraciunIT ConsultantCommented:
I don't think PHP is the best tool for this. You'll need exec() to run top (assuming your host runs something with X at the end), and it's disabled on most servers.

For Windows, just use Powershell and you can get pretty much any report you want.

For Linux, Perl or Python with some kind of graph plugin.

HTH,
Dan
vishnu kalakotaAuthor Commented:
Thank you for your replay..

i just need to know on my local system the % of memory used by the top 6 process..
do u think this will give correct answer.

ps -eo pmem,vsize,pid | sort -nr | head -6
Dan CraciunIT ConsultantCommented:
That will give you the pid for the top 6 processes, sorted first by %mem usage (which will usually be under 1%, on systems with lots of RAM) and then by virtual size.

 ps axo pmem,vsize,pid | sort -r | head -7

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

vishnu kalakotaAuthor Commented:
HI

5.3  3965284   380
 4.3  3084644   273
 3.0  3670524   203
 2.9  3642052  1500
 2.6  3884468   147
 2.4  3123272   151
 2.3  3494384  1468


i have got result somthing like this.. i think first column is %Pmem, second Vsize , Third is PID .


My Aim is to get 6 most memory-hungry processes  that are using the largest amount of RAM.

and i have draw a graph used on this.
so can i use the above command r not

thank you so much..
Dan CraciunIT ConsultantCommented:
Yes, you can use those for graphing purposes.

How much RAM do you have in that system?
vishnu kalakotaAuthor Commented:
8 gb RAM
vishnu kalakotaAuthor Commented:
working
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.