How to enable the ps -ux option on busybox?

spanky picture spanky · Feb 14, 2013 · Viewed 9.8k times · Source

I have stripped down busy box for my embedded linux.Currently the busy box supports only ps -w option.

I need to sample an application for its CPU and Memory usage and the sample should be atleast 5 per sec. Top command gives 1 sample per sec.

I am currently using ps -ux to get the CPU and Memory usage for this particular process and using vmstat and meminfo to get the overall CPU and memory usage. I am straightaway redirecting the info obtained from "ps -ux" ,"meminfo","vmstat" to a file and later on I will parse this file to see the trend for this particular process with respect to overall CPU and Memory Usage thats how I am getting 3-5 samples per second.

The problem is I am not able to enable the "ps -ux" on my busy box. How to enable the ps -ux option on busy box which has a stripped down linux version?

Answer

Robert Calhoun picture Robert Calhoun · Jul 22, 2014

Another option would be to read whatever process statistics you need out of the kernel's /proc virtual directory. /proc/PID/stat has all kinds of good stuff, and you can read it as often as you want.