Check memory per processes and subprocesses

前端 未结 1 1997
一个人的身影
一个人的身影 2021-01-16 11:35

I am attempted to create a script that show how much each process and subprocess of mysqld is using. You can see what I have done in my code.

#!/bin/bash
#fi         


        
相关标签:
1条回答
  • 2021-01-16 12:05

    Calculating a processes memory usage is... complicated. I generally use a proc's RSS -- Resident Set Size -- the amount of memory a process is holding in memory, that isn't shared by other procs.

    The following finds the process ID of the MySQL daemon, and uses ps to output the RSS value with no header. Lastly it multiplies this by four to get the RSS size in KiB. (Default pagesize is 4 KiB.)

    ps has tons of information -- have fun!

    shell

    ps -o rss= -p `pidof mysqld` | awk '{print $1*4, "KiB"}'
    

    output

    7808 KiB
    
    0 讨论(0)
提交回复
热议问题