Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting CPU use for specific process periodically

I have a running demo on a Linux server which consumes quite a bit of CPU and Memory usage. These parameters keep changing based on the load of the running demo. I want to extract the CPU usage and Memory usage periodically , i.e. every 3-4 sec and create a plot of the extracted result.

Considering the process as " Running Demo", on the terminal I typed:

ps aux |grep Running Demo | awk '{print $3 $4}'

This gives me the CPU and Memory usage of Running Demo. But I want the next two things i.e. 1) get this result outputted every 3-4 sec. 2) Make a plot of the generated result.

Any help or suggestion will be highly appreciated. I am a starter in this community.

Thanks

like image 786
Quick Silver Avatar asked Sep 03 '26 17:09

Quick Silver


1 Answers

What you are trying to do is well known as an existing project :

See Munin

EXAMPLE

enter image description here

NOTE

  • it's supported by the Open Source community, so...
  • it will be stronger
  • don't run odd commands like ps aux |grep Running Demo | awk '{print $3 $4}' but ps auxw | awk '/Running Demo/{print $3 $4}'
  • many plugins exists and works for basics : CPU, RAM, FW, Apache and many more
  • if you really need gnuplot, see a top 3 on a goggle search http://blah.token.ro/post/249956031/using-gnuplot-to-graph-process-cpu-usage
like image 113
Gilles Quenot Avatar answered Sep 05 '26 09:09

Gilles Quenot