Skip to content

Instantly share code, notes, and snippets.

@dotmanila
Last active October 11, 2015 04:57
Show Gist options
  • Save dotmanila/3805947 to your computer and use it in GitHub Desktop.
Save dotmanila/3805947 to your computer and use it in GitHub Desktop.
mysql monitor
#!/bin/bash
WD=/root/monitor
USR=<mysqlrootuser>
PWD=<mysqlrootpass>
mkdir -p $WD
cd $WD
while [ 1 ]
do
_d="dta_$(date +%Y-%m-%d_%H)"
mkdir -p $_d
d=$(date +%Y-%m-%d_%H_%M_%S)
echo $d
#p=$(pidof mysqld)
( vmstat 1 9 > $_d/vmstat-$d ) &
( iostat -kx 1 9 > $_d/iostat-$d ) &
( cat /proc/$p/maps > $_d/maps-$d ) &
( cat /proc/$p/smaps > $_d/smaps-$d ) &
( cat /proc/meminfo > $_d/meminfo-$d ) &
( ps -eo ppid,pid,user,stat,pcpu,comm,wchan:32 > $_d/ps-$d ) &
( mysql -u$USR -p$PWD -e 'show full processlist \G' > $_d/processlist-$d ) &
( mysql -u$USR -p$PWD -e 'show engine innodb status \G' > $_d/innodbstatus-$d ) &
( mysql -u$USR -p$PWD -e 'show global status' > $_d/globalstatus-$d ) &
#( top -b -n1 > $_d/top-$d ) &
#touch http-gdb-list.out
#cat http-gdb-list.out|sort > t
#cat t > http-gdb-list.out
#ps auxf | grep httpd | grep ' D '|awk '{ print $2 }'|sort> httpd-d-list.out
#for h in $(comm -13 <(sort http-gdb-list.out) <(sort httpd-d-list.out)); do
# gdb -ex 'set pagination 0' -ex 'thread apply all bt full' -batch /usr/sbin/httpd $h > $_d/gdb-$h-$d
# echo $h >> http-gdb-list.out
#done
find $WD -maxdepth 1 -mmin +1440 -type d -exec rm -rf {} \;
sleep 10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment