Search code examples
linuxcpucpu-usagemeasure

Dstat CPU usage for one specific process


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.


Solution

  • 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