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
#file contains the output of: pstree mysql -a -p |awk '{print $1;}' | sed 's/|- {mysqld},//' >> psadd
filename='psadd'
#total= '0'
echo Start
while read p; do
memU= cat /proc/$p/smaps |grep -e Private -e Shared |awk '{print $2}' |awk '{total = total + $1}END{print total}'
echo "Process ID:"$p "Memory Usage:"$memU
total="$((total+memu))"
echo "This is the current running total:" $total
done < $filename
echo "Total=" $total
Please if you have any ideas they will be much appreciated.