Thursday, 29 December 2011

advanced top command tutorial

Yesterday i finished reading the book "High performance Mysql- Optimization, backups, replication and Load balancing" by jermy D. Zawodny & Derek J. Balling. It was a old book. Edition says as June 2004. That time clustering was not so mature hence it is lacking in that field. Still it was presented in a simple and easy to understand manner. I learnt quite a lot of things from that book. I was a novice mysql user. Now i am confident of taking up bigger challenges in mysql, aleast it put me in path where i can make good judgement of what decision i have to take , where to look in case of error and understand what the experts are saying and apply them here. I am on path to becoming mysql dba expert. Not just because of this book, it is also because i have been going through standford university db classes. And also because i am going to take up mysql dba certification. I am still reading.

I always wanted to know more about what are the options available for top and ps , rather than simple typing top and interpreting the result. In ps i use to do just ps -ef. But found that -ef for ps is a linux specific thing and doesnt work in freebsd. Where i used the older one of ps i used to, ie. ps aux. Today i learnt about options to top. I am putting up the options that interest me and not all i learnt.

Some of Top's interactive command list

d or s => change the display refresh rate.
W => Write current settings to file.
M => Sort by %Mem
N =>  Sort by %PID
P =>  Sort by %CPU (defualt)
T =>  Sort by Time+
O =>  Sort by  any other field selected from list presented upon pressing O.
R =>  Reverse the order sort of the selected field (above).
c => show commands with absolute path  and its arguments.

Some of Top's command line options

-n 5 => iterate for 5 times of display refresh and then exit.
-b -n 5 > top-out.txt  => run in batch mode and iterate for 5 times and output to top-out.txt. Note that just '-n 5 > top-out.txt' will create binary data in the top-out.txt. It is necessary to use -b to output in plain text.

No comments:

Post a Comment