Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1689050
  • 博文数量: 107
  • 博客积分: 1715
  • 博客等级: 上尉
  • 技术积分: 3168
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-18 18:42
个人简介

阿里巴巴DBA,原去哪儿网DBA。专注于MySQL源码研究、DBA运维、CGroup虚拟化及Linux Kernel源码研究等。 github:https://github.com/HengWang/ Email:king_wangheng@163.com 微博 :@王恒-Henry QQ :506437736

文章分类

全部博文(107)

文章存档

2014年(2)

2013年(38)

2012年(67)

分类: Mysql/postgreSQL

2012-05-11 15:17:42

4、analyze文件夹
1)analyze_global_innodb_dirty_page_ratio.sh脚本

点击(此处)折叠或打开

  1. #! /bin/sh

  2. ###########################################################
  3. # Copyright (c) 2012, Heng.Wang. All rights reserved.
  4. #
  5. # This program is used to analyze the dirty pages ratio.
  6. ###########################################################

  7. # set -x

  8. # Get the key value of input arguments format like '--args=value'.
  9. get_key_value()
  10. {
  11.     echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
  12. }

  13. # Usage will be helpful when you need to input the valid arguments.
  14. usage()
  15. {
  16. cat <<EOF
  17. Usage: $0 [configure-options]
  18.   -?, --help Show this help message.
  19.   --input=<> Set the input file path.
  20.   --outputdir=<> Set the output directory.

  21. Note: this script is intended for internal use by developers.

  22. EOF
  23. }

  24. # Print the default value of the arguments of the script.
  25. print_default()
  26. {
  27. cat <<EOF
  28.   The default value of the variables:
  29.   input $INPUT
  30.   outputdir $OUTPUTDIR

  31. EOF
  32. }

  33. # Parse the input arguments and get the value of the input argument.
  34. parse_options()
  35. {
  36.   while test $# -gt 0
  37.   do
  38.     case "$1" in
  39.     --input=*)
  40.       INPUT=`get_key_value "$1"`;;
  41.     --outputdir=*)
  42.       OUTPUTDIR=`get_key_value "$1"`;;
  43.     -? | --help)
  44.       usage
  45.       print_default
  46.       exit 0;;
  47.     *)
  48.       echo "Unknown option '$1'"
  49.       exit 1;;
  50.     esac
  51.     shift
  52.   done
  53. }



  54. #################################################################
  55. INPUT=""
  56. OUTPUTDIR=/opt/result

  57. parse_options "$@"

  58. if [ -z $INPUT ]
  59. then
  60.   echo "Please give the input file address!"
  61.   exit -1
  62. fi

  63. if [ -f $INPUT ]
  64. then
  65.   [[ -d $OUTPUTDIR ]] || mkdir -p $OUTPUTDIR
  66.   
  67.   dir1=`dirname $INPUT`
  68.   dir2=`dirname $dir1`
  69.   
  70.   cat $INPUT | awk ' BEGIN { dt=-1;dr=-1;df=-1 } /Innodb_buffer_pool_pages_data/ \
  71.   { if (dt==-1) { dt=$4} else { dt+=$4 } } /Innodb_buffer_pool_pages_dirty/ \
  72.   { if (dr==-1) { dr=$4} else { dr+=$4 } } /Innodb_buffer_pool_pages_free/ \
  73.   { if (df==-1) { df=$4} else { df+=$4 } ; print (100*dr)/(1+dt+df) } ' \
  74.   >$OUTPUTDIR/dirty_page_ratio_${dir2##*/}_${dir1##*/}.result
  75.   exit 0
  76. else
  77.   echo "The input file is not exist!"
  78.   echo "Please be double check the input file!"
  79.   exit -1
  80. fi
2、analyze_global_innodb_page_flushed.sh脚本

点击(此处)折叠或打开

  1. #! /bin/sh

  2. ###########################################################
  3. # Copyright (c) 2012, Heng.Wang. All rights reserved.
  4. #
  5. # This program is used to analyze the dirty pages ratio.
  6. ###########################################################

  7. # set -x

  8. # Get the key value of input arguments format like '--args=value'.
  9. get_key_value()
  10. {
  11.     echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
  12. }

  13. # Usage will be helpful when you need to input the valid arguments.
  14. usage()
  15. {
  16. cat <<EOF
  17. Usage: $0 [configure-options]
  18.   -?, --help Show this help message.
  19.   --input=<> Set the input file path.
  20.   --outputdir=<> Set the output directory.

  21. Note: this script is intended for internal use by developers.

  22. EOF
  23. }

  24. # Print the default value of the arguments of the script.
  25. print_default()
  26. {
  27. cat <<EOF
  28.   The default value of the variables:
  29.   input $INPUT
  30.   outputdir $OUTPUTDIR

  31. EOF
  32. }

  33. # Parse the input arguments and get the value of the input argument.
  34. parse_options()
  35. {
  36.   while test $# -gt 0
  37.   do
  38.     case "$1" in
  39.     --input=*)
  40.       INPUT=`get_key_value "$1"`;;
  41.     --outputdir=*)
  42.       OUTPUTDIR=`get_key_value "$1"`;;
  43.     -? | --help)
  44.       usage
  45.       print_default
  46.       exit 0;;
  47.     *)
  48.       echo "Unknown option '$1'"
  49.       exit 1;;
  50.     esac
  51.     shift
  52.   done
  53. }



  54. #################################################################
  55. INPUT=""
  56. OUTPUTDIR=/opt/result

  57. parse_options "$@"

  58. if [ -z $INPUT ]
  59. then
  60.   echo "Please give the input file address!"
  61.   exit -1
  62. fi

  63. if [ -f $INPUT ]
  64. then
  65.   [[ -d $OUTPUTDIR ]] || mkdir -p $OUTPUTDIR
  66.   
  67.   dir1=`dirname $INPUT`
  68.   dir2=`dirname $dir1`
  69.   
  70.   cat $INPUT | awk ' BEGIN { df=0 ; dl=0; } /Innodb_buffer_pool_pages_flushed[\s]/ \
  71.   { df=$4 } /Innodb_buffer_pool_pages_LRU_flushed/ { dl=$4; print df,dl } ' \
  72.   >$OUTPUTDIR/flushed_pages_${dir2##*/}_${dir1##*/}.result
  73. else
  74.   echo "The input file is not exist!"
  75.   echo "Please be double check the input file!"
  76.   exit -1
  77. fi
3)analyze_innodb_checkpoint.sh脚本

点击(此处)折叠或打开

  1. #! /bin/sh

  2. ###########################################################
  3. # Copyright (c) 2012, Heng.Wang. All rights reserved.
  4. #
  5. # This program is used to analyze the checkpoint.
  6. ###########################################################

  7. # set -x

  8. # Get the key value of input arguments format like '--args=value'.
  9. get_key_value()
  10. {
  11.     echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
  12. }

  13. # Usage will be helpful when you need to input the valid arguments.
  14. usage()
  15. {
  16. cat <<EOF
  17. Usage: $0 [configure-options]
  18.   -?, --help Show this help message.
  19.   --input=<> Set the input file path.
  20.   --outputdir=<> Set the output directory.

  21. Note: this script is intended for internal use by developers.

  22. EOF
  23. }

  24. # Print the default value of the arguments of the script.
  25. print_default()
  26. {
  27. cat <<EOF
  28.   The default value of the variables:
  29.   input $INPUT
  30.   outputdir $OUTPUTDIR

  31. EOF
  32. }

  33. # Parse the input arguments and get the value of the input argument.
  34. parse_options()
  35. {
  36.   while test $# -gt 0
  37.   do
  38.     case "$1" in
  39.     --input=*)
  40.       INPUT=`get_key_value "$1"`;;
  41.     --outputdir=*)
  42.       OUTPUTDIR=`get_key_value "$1"`;;
  43.     -? | --help)
  44.       usage
  45.       print_default
  46.       exit 0;;
  47.     *)
  48.       echo "Unknown option '$1'"
  49.       exit 1;;
  50.     esac
  51.     shift
  52.   done
  53. }



  54. #################################################################
  55. INPUT=""
  56. OUTPUTDIR=/opt/result

  57. parse_options "$@"

  58. if [ -z $INPUT ]
  59. then
  60.   echo "Please give the input file address!"
  61.   exit -1
  62. fi

  63. if [ -f $INPUT ]
  64. then
  65.   [[ -d $OUTPUTDIR ]] || mkdir -p $OUTPUTDIR
  66.   
  67.   dir1=`dirname $INPUT`
  68.   dir2=`dirname $dir1`

  69.   cat $INPUT | awk ' BEGIN { } /Log sequence number/ {st=$4 } /Last checkpoint at/ \
  70.   { ed=$4; print (st-ed)/1024/1024 } '>$OUTPUTDIR/checkpoint_${dir2##*/}_${dir1##*/}.result
  71.   exit 0
  72. else
  73.   echo "The input file is not exist!"
  74.   echo "Please be double check the input file!"
  75.   exit -1
  76. fi

4)analyze_innodb_log_flushed_fallbehind.sh脚本

点击(此处)折叠或打开

  1. #! /bin/sh

  2. ###########################################################
  3. # Copyright (c) 2012, Heng.Wang. All rights reserved.
  4. #
  5. # This program is used to analyze the dirty pages ratio.
  6. ###########################################################

  7. # set -x

  8. # Get the key value of input arguments format like '--args=value'.
  9. get_key_value()
  10. {
  11.     echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
  12. }

  13. # Usage will be helpful when you need to input the valid arguments.
  14. usage()
  15. {
  16. cat <<EOF
  17. Usage: $0 [configure-options]
  18.   -?, --help Show this help message.
  19.   --input=<> Set the input file path.
  20.   --outputdir=<> Set the output directory.

  21. Note: this script is intended for internal use by developers.

  22. EOF
  23. }

  24. # Print the default value of the arguments of the script.
  25. print_default()
  26. {
  27. cat <<EOF
  28.   The default value of the variables:
  29.   input $INPUT
  30.   outputdir $OUTPUTDIR

  31. EOF
  32. }

  33. # Parse the input arguments and get the value of the input argument.
  34. parse_options()
  35. {
  36.   while test $# -gt 0
  37.   do
  38.     case "$1" in
  39.     --input=*)
  40.       INPUT=`get_key_value "$1"`;;
  41.     --outputdir=*)
  42.       OUTPUTDIR=`get_key_value "$1"`;;
  43.     -? | --help)
  44.       usage
  45.       print_default
  46.       exit 0;;
  47.     *)
  48.       echo "Unknown option '$1'"
  49.       exit 1;;
  50.     esac
  51.     shift
  52.   done
  53. }



  54. #################################################################
  55. INPUT=""
  56. OUTPUTDIR=/opt/result

  57. parse_options "$@"

  58. if [ -z $INPUT ]
  59. then
  60.   echo "Please give the input file address!"
  61.   exit -1
  62. fi

  63. if [ -f $INPUT ]
  64. then
  65.   [[ -d $OUTPUTDIR ]] || mkdir -p $OUTPUTDIR
  66.   
  67.   dir1=`dirname $INPUT`
  68.   dir2=`dirname $dir1`
  69.   
  70.   cat $INPUT | awk ' BEGIN { } /Log sequence number/ {st=$4 } /Log flushed up to/ \
  71.   { ed=$5; print (st-ed) } ' > $OUTPUTDIR/log_flushed_fallbehind_${dir2##*/}_${dir1##*/}.result
  72. else
  73.   echo "The input file is not exist!"
  74.   echo "Please be double check the input file!"
  75.   exit -1
  76. fi
5)analyze_sysbench_performance_args.sh脚本

点击(此处)折叠或打开

  1. #! /bin/sh

  2. ###########################################################
  3. # Copyright (c) 2012, Heng.Wang. All rights reserved.
  4. #
  5. # This program is used to analyze the sysbench test report
  6. # and get the performance value of per second (transactions,
  7. # deadlocks, read/write requests and other operations).
  8. ###########################################################

  9. # set -x

  10. # Get the key value of input arguments format like '--args=value'.
  11. get_key_value()
  12. {
  13.     echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
  14. }

  15. # Usage will be helpful when you need to input the valid arguments.
  16. usage()
  17. {
  18. cat <<EOF
  19. Usage: $0 [configure-options]
  20.   -?, --help Show this help message.
  21.   --input=<> Set the input file path.
  22.   --outputdir=<> Set the output directory.

  23. Note: this script is intended for internal use by developers.

  24. EOF
  25. }

  26. # Print the default value of the arguments of the script.
  27. print_default()
  28. {
  29. cat <<EOF
  30.   The default value of the variables:
  31.   input $INPUT
  32.   outputdir $OUTPUTDIR

  33. EOF
  34. }

  35. # Parse the input arguments and get the value of the input argument.
  36. parse_options()
  37. {
  38.   while test $# -gt 0
  39.   do
  40.     case "$1" in
  41.     --input=*)
  42.       INPUT=`get_key_value "$1"`;;
  43.     --outputdir=*)
  44.       OUTPUTDIR=`get_key_value "$1"`;;
  45.     -? | --help)
  46.       usage
  47.       print_default
  48.       exit 0;;
  49.     *)
  50.       echo "Unknown option '$1'"
  51.       exit 1;;
  52.     esac
  53.     shift
  54.   done
  55. }



  56. #################################################################
  57. INPUT=""
  58. OUTPUTDIR=/opt/result

  59. parse_options "$@"

  60. if [ -z $INPUT ]
  61. then
  62.   echo "Please give the input file address!"
  63.   exit -1
  64. fi

  65. if [ -f $INPUT ]
  66. then
  67.   [[ -d $OUTPUTDIR ]] || mkdir -p $OUTPUTDIR
  68.   
  69.   dir1=`dirname $INPUT`
  70.   dir2=`dirname $dir1`
  71.       
  72.   cat $INPUT | awk ' BEGIN { ts=0 ; dl=0; rwq=0; oo=0; } /transactions/ \
  73.   { ts=$3 } /deadlocks/ { dl=$3 } /read\/write requests/ { rwq=$4 } /other operations/ \
  74.   { oo=$4; print substr(ts,2),substr(dl,2),substr(rwq,2),substr(oo,2) }' \
  75.   >> $OUTPUTDIR/sysbench_perform_per_second_${dir2##*/}.result
  76. else
  77.   echo "The input file is not exist!"
  78.   echo "Please be double check the input file!"
  79.   exit -1
  80. fi

6)analyze_sysbench_report脚本

点击(此处)折叠或打开

  1. #! /bin/sh

  2. ###########################################################
  3. # Copyright (c) 2012, Heng.Wang. All rights reserved.
  4. #
  5. # This program is used to analyze the sysbench test report.
  6. ###########################################################

  7. # set -x

  8. # Get the key value of input arguments format like '--args=value'.
  9. get_key_value()
  10. {
  11.     echo "$1" | sed 's/^--[a-zA-Z_-]*=//'
  12. }

  13. # Usage will be helpful when you need to input the valid arguments.
  14. usage()
  15. {
  16. cat <<EOF
  17. Usage: $0 [configure-options]
  18.   -?, --help Show this help message.
  19.   --input=<> Set the input file path.
  20.   --outputdir=<> Set the output directory.

  21. Note: this script is intended for internal use by developers.

  22. EOF
  23. }

  24. # Print the default value of the arguments of the script.
  25. print_default()
  26. {
  27. cat <<EOF
  28.   The default value of the variables:
  29.   input $INPUT
  30.   outputdir $OUTPUTDIR

  31. EOF
  32. }

  33. # Parse the input arguments and get the value of the input argument.
  34. parse_options()
  35. {
  36.   while test $# -gt 0
  37.   do
  38.     case "$1" in
  39.     --input=*)
  40.       INPUT=`get_key_value "$1"`;;
  41.     --outputdir=*)
  42.       OUTPUTDIR=`get_key_value "$1"`;;
  43.     -? | --help)
  44.       usage
  45.       print_default
  46.       exit 0;;
  47.     *)
  48.       echo "Unknown option '$1'"
  49.       exit 1;;
  50.     esac
  51.     shift
  52.   done
  53. }



  54. #################################################################
  55. INPUT=""
  56. OUTPUTDIR=/opt/result

  57. parse_options "$@"

  58. if [ -z $INPUT ]
  59. then
  60.   echo "Please give the input file address!"
  61.   exit -1
  62. fi

  63. if [ -f $INPUT ]
  64. then
  65.   [[ -d $OUTPUTDIR ]] || mkdir -p $OUTPUTDIR
  66.   
  67.   dir1=`dirname $INPUT`
  68.   dir2=`dirname $dir1`
  69.   
  70.   sed -n '/OLTP test statistics/,+30p' $INPUT > $OUTPUTDIR/sysbench_report_${dir2##*/}_${dir1##*/}.result
  71. else
  72.   echo "The input file is not exist!"
  73.   echo "Please be double check the input file!"
  74.   exit -1
  75. fi




阅读(2590) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~