[ale] monitoring memory

Geoffrey lists at serioustechnology.com
Thu Oct 25 16:13:58 EDT 2007


Jay Loden wrote:
> 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}'`

ps aux| awk '/awk/ {next;} /mysqld/ '{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))
> 
> -----
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
> 


-- 
Until later, Geoffrey

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
  - Benjamin Franklin



More information about the Ale mailing list