[ale] monitoring memory

Jay Loden ale at jayloden.com
Thu Oct 25 15:37:41 EDT 2007


Jay Loden wrote:
> I'm sure there are other ways to do it which make for an interesting 
> exercise in shell scripting or perl fu :) For MySQL itself, I've had 
> reason in the past to need to calculate the MySQL total memory usage 
> also, so I hacked up a simple command/script that gives the MySQL 
> process total memory usage (also in MB). Unfortunately, I don't have 
> that handy at the moment but I will post back to the list when I can 
> find a copy of it. 

Replying to myself...here's the script mentioned in my last email: 

------

#!/bin/sh

MYSQL_PIDS=`ps aux | grep mysqld | grep -v grep | awk '{print $2}'`
total=0
for PID in $MYSQL_PIDS; do
        MEM=`pmap $PID | tail -1 | awk '{print $2}' | tr -d 'K'`
        total=$(($total + $MEM))
done
echo $(($total / 1024))

-----



More information about the Ale mailing list