damonitor / damo

DAMON user-space tool
GNU General Public License v2.0
18 stars 3 forks source link

Add cpu usage stat for kdamond #14

Closed m8 closed 2 months ago

m8 commented 2 months ago

This commit adds CPU usage stat for kdamond by parsing the output of ps, which will then be used in damo status. I would also like to ask if I should implement this as a separate function, such as is_kdamond_running, or if the current approach is ok.

kdamond 0
    state: on, pid: 85219, cpu usage: 1.2
    context 0
        ops: vaddr
        target 0
            pid: 85201
        intervals: sample 5 ms, aggr 100 ms, update 1 s
        nr_regions: [10, 1,000]
sjp38 commented 2 months ago

Thank you for this nice PR! I'm wondering if the changed output could break any existing workflows (e.g., damo status output parser scripts), though. The probability is pretty low, but I'd like to ensure this never breaks something. What do you think about making this output optional using another command line, e.g., damo status --show_cpu_usage?

m8 commented 2 months ago

Thanks @sjp38 for the feedback, i just updated the code.

sjp38 commented 2 months ago

Thank you for this great PR, @m8!