adding mysql_threads
This commit is contained in:
parent
b5f0c0ef82
commit
1c3f05e36b
1 changed files with 26 additions and 0 deletions
26
shell/mysql_threads.sh
Executable file
26
shell/mysql_threads.sh
Executable file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# crontab:
|
||||||
|
# */10 * * * * /usr/local/sbin/mysql_threads.sh
|
||||||
|
#
|
||||||
|
# logrotate:
|
||||||
|
# /var/log/mysql_threads.log {
|
||||||
|
# rotate 4
|
||||||
|
# missingok
|
||||||
|
# notifempty
|
||||||
|
# size 5M
|
||||||
|
# weekly
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
SERVER=localhost
|
||||||
|
LOG=/var/log/mysql_threads.log
|
||||||
|
DTS=$(date +"%Y-%m-%d %H:%M:%S %Z")
|
||||||
|
|
||||||
|
THREADS=$(mysql -h ${SERVER} -B -N -e "SHOW STATUS LIKE 'Threads_connected';" | tr "\011" " ")
|
||||||
|
USERS=$(mysql -h ${SERVER} -B -N -e "SELECT DISTINCT USER AS users, COUNT(*) FROM information_schema.processlist GROUP BY users;" | tr "\011" ":" | tr "\n" "," | sed '$s/.$//')
|
||||||
|
|
||||||
|
echo "${DTS} ${THREADS}, Users_connected [${USERS}]" >> "${LOG}"
|
||||||
|
|
||||||
|
exit 0
|
||||||
Loading…
Add table
Add a link
Reference in a new issue