Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Linux process resource usage (cpu,disk,network)

I want to use the /proc to find the resource usage of a particular process every second. The resources include cputime, disk usage and network usage. I looked at /proc/pid/stat , but I am not sure whether I am getting the required details. I want all 3 resource usage and I want to monitor them every second.

like image 817
sethu Avatar asked Jul 08 '11 03:07

sethu


People also ask

What command shows you CPU and memory utilization for running processes in Linux?

The top command (table of processes) displays the processor activity of your Linux box and also displays tasks managed by the kernel in real-time. It also shows information about CPU and memory utilization of a list of running processes.

How do I find the top 10 CPU consuming process in Linux?

Use ps Command to Find Top Processes by Memory and CPU Usage ps is a Linux command-line utility with many options that helps you to display output in different formats. You can use the ps command with –sort argument to sort the output by memory and CPU usage.


1 Answers

Some newer kernels have /proc/<pid_of_process>/io file. This is where IO stats are. It is not documented in man proc, but you can try to figure out the numbers yourself.

Hope it helps. Alex.

like image 144
Alexander Sandler Avatar answered Oct 13 '22 16:10

Alexander Sandler