Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does pt-stalk monitor MySQL operation

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Xiaobian to share with you how pt-stalk monitor MySQL operation, I hope you have something to gain after reading this article, let's discuss it together!

1. Using pt-stalk

pt-stalk --collect-tcpdump --function status \

--variable Threads_connected --threshold 2500 \

--daemonize -- --user=root --password=YOURPASSWORD

The above command indicates that pt-stalk runs in the background (--daemonize) and monitors the Threads_connected status value in SHOW GLOBAL STATUS, triggering the collection of host and MySQL performance and status information if the value exceeds 2500. pt-stalk checks the status value every second and starts collecting if the trigger condition is met five times in a row.

--collect-tcpdump means that in addition to collecting basic information, tcpdump will also be used to collect network packets at that time. Similarly, --collect-gdb can also be used.

2. pt-stalk How to connect MySQL

In the above command argument,"---user=root --password=YOURPASSWORD" means that all arguments after "--" will be used for mysql and mysqladmin commands, so make sure you give the correct username and password here. Here is the syntax given in man pt-stalk:

SYNOPSIS

Usage: pt-stalk [OPTIONS] [-- MYSQL OPTIONS]

See earlier that [OPTIONS] is the parameter used by pt-stalk, and [-- MYSQL OPTIONS] is the parameter used by mysql and mysqladmin.

3. Working status of pt-stalk

pt-stalk is a background program. By default, we can check the running status of pt-stalk through the file/var/log/pt-stalk.log:

tail -f /var/log/pt-stalk.log

2012_06_05_00_00_35 Check results: Threads_connected=1641, matched=no

2012_06_05_00_00_36 Check results: Threads_connected=1641, matched=no

2012_06_05_00_00_37 Check results: Threads_connected=1641, matched=no

2012_06_05_00_00_38 Check results: Threads_connected=1641, matched=no

2012_06_05_00_00_39 Check results: Threads_connected=1641, matched=no

2012_06_05_00_00_40 Check results: Threads_connected=1641, matched=no

2012_06_05_00_00_41 Check results: Threads_connected=1641, matched=no

You can also specify a desired log directory and file with the--log parameter.

4. Performance and status data collected by pt-stalk

The default pt-stalk places the collected data in the directory/var/lib/pt-stalk. You can specify the directory you want using the parameter--dest. Here is the data file collected after a pt-stalk trigger:

These data are all raw data, and we can analyze whether MySQL or the host is abnormal at that time according to these data.

5. Trigger conditions for pt-stalk

In the example above, the trigger parameter is: "--function status --variable Threads_connected --threshold 2500," meaning that data collection is triggered when the MySQL status value Threads_connected exceeds 2500. Common trigger conditions can also be used Threads_running and so on.

In addition, you can also use the result trigger in SHOW PROCESSLIST, for example,"--function processlist --variable State --match statistics --threshold 10" means that the number of threads with the value of statistics in the State column in the show processlist exceeds 10, triggering collection.

6. Some other useful parameters

--iterations: This parameter specifies that pt-stalk exits after collecting several fault scenes. The default pt-stalk will always run

--run-time: This parameter specifies how long data is collected after collection is triggered. The default is 30 seconds.

--sleep: To prevent data collection from being triggered all the time, this parameter specifies that after a trigger, you must sleep for a period of time before continuing to observe and trigger collection. Default is 300 seconds.

--interval: By default pt-stalk checks status data every second to see if collection needs to be triggered. This parameter specifies the interval, which defaults to 1 second.

--cycles: default pt-stalk Collection is triggered only when five consecutive state values are observed that satisfy the trigger condition. This parameter controls how many times the condition needs to be met in succession, and collection is triggered. The default is 5 times.

After reading this article, I believe you have a certain understanding of "pt-stalk how to monitor MySQL operation". If you want to know more about it, please pay attention to the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report