LP #1644694: pt-stalk get wrong mysqld pid when the host installed multi mysql instance

Description

**Reported in Launchpad by zhechen last update 25-11-2016 14:13:03

host env:
Centos 6.8
percona-toolkit-2.2.19

two mysql instance:
$ pidof mysqld
33530 17881

my host have two mysql instance, 3304 port(pid: 17881) and 3306 port(pid: 33530), when I use pt-stalk to monitor 3304 port, the mysql info logs in /var/lib/pt-stalk/ is about 3306 port, this is wrong, I just want log the mysql 3304 port.

the following code in pt-stalk mabye get wrong mysql pid:

792 collect() {
793 local d="$1" # directory to save results in
794 local p="$2" # prefix for each result file
795
796 local mysqld_pid=$(_pidof mysqld | awk '{print $1; exit;}')
797

the subsequent mysql info will be wrong when mysqld_pid is wrong, pt-stalk should read mysql pid_file to get right pid number.

Environment

None

Smart Checklist

Activity

Show:

Carlos Salguero August 25, 2021 at 4:16 PM
Edited

Suggestion:

Get the MySQL port using:

then 

 

The grep and cut are there because lsof with a port will list also secodaries listening:

 

lpjirasync January 24, 2018 at 9:25 PM

**Comment from Launchpad by: Jericho Rivera on: 25-11-2016 10:10:25

With port=3307 option only it will not pick the right instance:
[root@multi ~]# bash -x pt-stalk --no-stalk --iterations=2 --sleep=30 --user=root --password=p3rc0na --port=3307 > stalk.out 2>&1
[root@multi ~]# grep ^port /var/lib/pt-stalk/*-variables
/var/lib/pt-stalk/2016_11_25_04_49_31-variables:port 3306
/var/lib/pt-stalk/2016_11_25_04_50_01-variables:port 3306

Using the socket will pick the right instance:
[root@multi ~]# bash -x pt-stalk --no-stalk --iterations=2 --sleep=30 --user=root --password=p3rc0na --socket=/tmp/mysql1.sock > stalk1.out 2>&1
[root@multi ~]# grep ^port /var/lib/pt-stalk/*-variables
/var/lib/pt-stalk/2016_11_25_04_49_31-variables:port 3306
/var/lib/pt-stalk/2016_11_25_04_50_01-variables:port 3306
/var/lib/pt-stalk/2016_11_25_04_57_36-variables:port 3307
/var/lib/pt-stalk/2016_11_25_04_58_06-variables:port 3307

attaching stalk.out file using the port=3307 option only

Done

Details

Assignee

Reporter

Priority

Components

Fix versions

Needs Review

Yes

Story Points

Smart Checklist

Created January 24, 2018 at 9:24 PM
Updated March 4, 2024 at 4:39 PM
Resolved October 1, 2021 at 12:27 PM