mysql: script "mysql_connections" to display a compact list of connections

pull/131/head
Jérémy Lecour 1 year ago committed by Jérémy Lecour
parent 32b5efa30e
commit bf49ec8df5
  1. 1
      CHANGELOG.md
  2. 37
      mysql/files/mysql_connections.sh
  3. 9
      mysql/tasks/utils.yml

@ -17,6 +17,7 @@ The **patch** part changes incrementally at each release.
* certbot: add script for manual deploy hooks execution
* listupgrade: crontab is configurable
* mongodb: create munin plugins directory if missing
* mysql: script "mysql_connections" to display a compact list of connections
* redis: instance service for Debian 11
### Changed

@ -0,0 +1,37 @@
#!/bin/sh
# Example:
# # mysql_compact_processes
# *************************** 1. row ***************************
# host_short:
# users: system user
# processes: 1
# *************************** 2. row ***************************
# host_short: 31.170.X.Z
# users: repl
# processes: 1
# *************************** 3. row ***************************
# host_short: sql00.evolix.net
# users: repl
# processes: 1
# *************************** 4. row ***************************
# host_short: sql02.evolix.net
# users: repl
# processes: 1
# *************************** 5. row ***************************
# host_short: localhost
# users: mysqladmin,percona
# processes: 2
# *************************** 6. row ***************************
# host_short: prod10.evolix.net
# users: user1,user2
# processes: 11
# *************************** 7. row ***************************
# host_short: prod11.evolix.net
# users: user3,user4,user5
# processes: 312
set -e
mysql -e "SELECT SUBSTRING_INDEX(host, ':', 1) AS host_short, GROUP_CONCAT(DISTINCT USER) AS users, COUNT(*) AS processes FROM information_schema.processlist GROUP BY host_short ORDER BY processes, host_short\G"

@ -199,3 +199,12 @@
force: no
tags:
- mysql
- name: "Install mysql_connections"
copy:
src: mysql_connections.sh
dest: "{{ _mysql_scripts_dir }}/mysql_connections"
mode: "0755"
force: no
tags:
- mysql

Loading…
Cancel
Save