11

Is it possible to measure the CPU and memory for one specific process with dstat? There is possiblilities to measure the most consuming CPU with --top-cputime but is it possible to measure a specific one?

I want to write to a file with --output to make a graph of it later, not with ">" operator.

2 Answers2

10

No, this is not possible with dstat currently.

I always envisioned to make this possible, but never got around to doing it.

Dag Wieers
  • 1,663
  • 13
  • 11
-3

You can use command | grep specific_text

for example test dstat | grep puppet

to saving output result in a log file you have two options :

using --output file dstat --time --cpu --top-cputime --output /tmp/dstat.log | grep puppet

using command > file dstat --time --cpu --top-cputime > /tmp/dstat.log | grep puppet

for appendind logs : dstat --time --cpu --top-cputime >> /tmp/dstat.log | grep puppet

here is screenshots of both commands

According to your comments may these commands helps you :

(1) save stats in a file dstat --time --cpu --top-cputime --output my.log

(2) apply filtering to log file and save results to file cat my.log | grep httpd > myhttpd.log

(3) final results cat myhttpd.log

see the screenshot of results here

Farshad
  • 1,465
  • 1
  • 9
  • 12
  • and if you want to write the content to a file, that wont work: dstat --time --cpu --top-cputime | grep puppet --output filen –  Apr 18 '15 at 13:33
  • The correct way to write to file is --output file, the > command doesn't write anything to the file. –  Apr 18 '15 at 13:50
  • check my answer updates and screen shot of both commands working properly ! – Farshad Apr 19 '15 at 05:51
  • Thanks for using your time to help. The problem is that its not writing only the process I am interested into the file. As you can see here: (https://www.dropbox.com/s/gdgvf8symzd1xja/IMPORTANT.png?dl=0) I am grepping for the process puppet, but in the file into writing other process also. I am only interested in puppet. –  Apr 19 '15 at 09:28
  • may these commands helps you : (1) `dstat --time --cpu --top-cputime --output my.log` (2) `cat my.log | grep httpd > myhttpd.log` (3) `cat myhttpd.log` see the screenshot http://farshadajdar.com/screenshot2.jpg – Farshad Apr 19 '15 at 11:57