You are here

Reading other processes memory

As you probably have experienced yet MySQL does not always provide all internal information as you might want to have them and as you are used to have from other RDBMS.

MySQL plans to improve this implementing the/a performance schema and its probably already partly done in MySQL 5.4. But who knows when this will be finished and what it contains at all...

What is not provided to me I want to gather myself... But how? Other RDBMS provide interfaces to attach applications directly to their memory to retrieve information. But MySQL does not. So I was looking for a way to read an other process memory.

I have no clue about programming and thus changing MySQL code was out of focus. Further I am looking for a solution you can use immediately on a running systems at consulting gigs. Some tries to read /proc/<pid>/mem with a little PHP script failed.

An article by Domas M. helped me. I do not have to write something myself I can use a tool already existing to do the work. But gdb is not installed on every machine and usually not at all on production machines. Further gdb is probably an overkill to just read memory of other processes.

But an other application to do this job I did not find. I just found some comments that ptrace is the way to do it. ptrace (man ptrace) is not a program (as for example strace) but an operating system function call.

When you are interested how I found out how to do it please continue reading here.

Taxonomy upgrade extras: 

Comments

[http://www.blogger.com/profile/07820955267400574921 Morgan] said... Very nice! I can see the real use with some of the InnoDB stats. The random sampling interval makes it very difficult to get good numbers to use for cacti/RRDTool graphs.
Morgancomment

[http://www.blogger.com/profile/11195863756524022642 Shinguz] said... Hi Morgan, Do not get this. With the script read_process_memory.sh you can sample at a specific interval with a timestamp in the record and write a *.csv. That must be ideal for Cacti or any other monitoring/graphing tool, is it not? You could even extend it to write directly to a database... Please elaborate a bit more your concern.
Shinguzcomment

[http://www.blogger.com/profile/07820955267400574921 Morgan] said... I just read what I wrote, sorry for not making sense. What I meant: The '''default''' INNODB STATUS method of showing statistics is for anywhere between 0 seconds to 60 seconds makes it difficult. 0-10 seconds is usually useless because it averages too much, and it's entirely unpredictable what interval InnoDB uses. Your script allows me to just get the current value (not an average). Brilliant!
Morgancomment

[http://www.blogger.com/profile/11195863756524022642 Shinguz] said... A colleague pointed out that I was missing some information: The operative worklog task is WL#2360 and its dependencies, WL#4034 is a raw-idea bin item of no current significance. The complete specification of the performance schema can be found here: [http://forge.mysql.com/worklog/task.php?id=2333 WL#2333: SHOW ENGINE ... LOCK STATUS] [http://forge.mysql.com/worklog/task.php?id=2360 WL#2360: Performance Schema] [http://forge.mysql.com/worklog/task.php?id=2515 WL#2515: Performance statements] [http://forge.mysql.com/worklog/task.php?id=3249 WL#3249: SHOW PROCESSLIST should show memory] [http://forge.mysql.com/worklog/task.php?id=4674 WL#4674: PERFORMANCE_SCHEMA Setup For Actors] [http://forge.mysql.com/worklog/task.php?id=4678 WL#4678: PERFORMANCE_SCHEMA Instrumenting File IO] [http://forge.mysql.com/worklog/task.php?id=4813 WL#4813: PERFORMANCE_SCHEMA Instrumenting Stages] [http://forge.mysql.com/worklog/task.php?id=4816 WL#4816: PERFORMANCE_SCHEMA Summaries] [http://forge.mysql.com/worklog/task.php?id=4895 WL#4895: PERFORMANCE_SCHEMA Instrumenting Table IO] [http://forge.mysql.com/worklog/task.php?id=4878 WL#4878: PERFORMANCE_SCHEMA Trace] [http://forge.mysql.com/worklog/task.php?id=4896 WL#4896: PERFORMANCE_SCHEMA Instrumenting Net IO] There is an implementation of WL#2360 which was demonstrated 11 months ago at the MySQL developer conference: [http://blogs.mysql.com/peterg/2009/02/05/mysql-performance-schema/ Blog post 1] [http://blogs.mysql.com/peterg/2009/02/06/mysql-performance-schema-2/ Blog post 2] [http://blogs.mysql.com/peterg/2009/02/09/mysql-performance-schema-3/ Blog post 3] [http://blogs.mysql.com/peterg/2009/02/10/mysql-performance-schema-4/ Blog post 4] [http://blogs.mysql.com/peterg/2009/02/11/mysql-performance-schema-5/ Blog post 5] [http://blogs.mysql.com/peterg/2009/02/12/mysql-performance-schema-6/ Blog post 6] [http://blogs.mysql.com/peterg/2009/02/13/todo-mysql-performance-schema-7/ Blog post 7] The source code of the server including the Performance Schema is available for [https://code.launchpad.net/~marc.alff/mysql-server/mysql-6.0-perfschema download from launchpad].
Shinguzcomment