Linux System performance Metrics sampling script

Source: Internet
Author: User
Tags redmine

The following script, written in redmine performance troubleshooting, is used to locate a sample of the system's performance bottleneck, with the source address ~/performancelog/collectlog.sh, scheduled to be placed in GitHub's Code Snippets Library.


Note: If the MySQL address or directory is replaced, the Dstat MySQL related data collection in this script needs to rewrite the code of its plugin's MySQL connection section. Note: If the MySQL address or directory is replaced, and you want to use the following script to collect data, you need to rewrite the MySQL connection section of the code, in order to let the script Dstat mysql-related data collection normal acquisition.

#!/bin/BASHCD/home/pset/performancelog/#createdir  forTodaytoday=`Date "+%y%m%d"`if[!-d $today]; Thenmkdir$today;fiCD $today #declare var to remember current Hour.hour=`Date "+%h"`Echo "Current hour is:"$hourpostfix="_nohup.log"Filenameofdstat= $hour"_"$today"_dstat"$postfix". csv"Echo$filenameOfDstatfilenameOfIostat= $hour"_"$today"_iostat"$postfixEcho$filenameOfIostatfilenameOfPidstat= $hour"_"$today"_pidstat"$postfixEcho$filenameOfPidstatfilenameOfFree= $hour"_"$today"_free"$postfixEcho$filenameOfFreefilenameOfMemInfo= $hour"_"$today"_meminfo"$postfixEcho$filenameOfMemInfofilenameOfUptime= $hour"_"$today"_uptime"$postfixEcho$filenameOfUptimefilenameOfMpstat= $hour"_"$today"_mpstat"$postfixEcho$filenameOfMpstatfilenameOfIOtop= $hour"_"$today"_iotop"$postfixEcho$filenameOfIOtopfilenameOfSar= $hour"_"$today"_sar"$postfixEcho$filenameOfSar #the ProcessID whichWe are intrestedinch.: mysqld ruby.binpidmysqld=`PS-e|grepmysqld.bin|awk 'nr==1 {print $}'' Pidruby=`PS-e|grepruby.bin|awk 'nr==1 {print $}'' Export Dstat_mysql_user='Root'Export Dstat_mysql_pwd='1111'nohup Dstat-T--mysql5-cmds--mysql5-io--mysql5-keys [email protected]-DF--disk-util--disk--mem--proc--top-cpu--top-latency--top-bio--io--sys--filesystem--tcp--vm--output $filenameOfD Stat1 3600&nohup Pidstat-P $pidMysqld-U-D-W-H2 1800> $filenameOfPidstat &nohup Mpstat-P All2 1800> $filenameOfMpstat &nohup iotop-P $pidMysqld-N1800-D2> $filenameOfIOtop &nohup Iostat-dxk2 1800> $filenameOfIostat &#nohup SAR-O $filenameOfSar2 1800&#nohup Free> $filenameOfFree &#nohupCat/proc/meminfo > $filenameOfMemInfo &#nohupUptime> $filenameOfUptime &# inchEvery day at April, run the shell script at1min past each hour.#1* *4*/root/shift_my_times.SH#1* *4*/home/pset/performancelog/collectlog.SHThe crontab is set to start hourly and collects data according to the frequency set in the script:1 0,4,Ten- at*4*/home/pset/performancelog/collectlogs.SH* * *4*/usr/local/bin/mycheckpoint--user=root--password=1111--socket=/redmine/mysql/tmp/mysql.sock--database=mycheckpoint

The key system indicators that generate this scenario show:
Pidstat: Can target a specific process, such as MySQL or other processes
Mpstat: Used to see if some CPU idle is abnormal during peak hours.
Dstat io: Used to record the point in time of each acquisition and to coordinate global CPU mem IO net MySQL metrics information

Related page: http://www.cnblogs.com/ToDoToTry/p/4462609.html

Linux System performance Metrics sampling script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.