I always end up using inline BASH scripts when I'm troubleshooting a server. Here are some simple but useful examples for ya.
1. Check MySQL Replication and Innodb History Status
shell> while true; do mysql -uusername -ppassword -e "show slave status\\\\G" |egrep "Read_Master_Log_Pos|Exec_Master_Log_Pos|Seconds_Behind_Master"; mysql -uadmin -padmin -e "show engine innodb status\\\\G" |grep "History list length"; sleep 2; done
2. Very fast show processlist searching for 1 user
shell> while true; do mysql -uusername -ppassword -e "show processlist" |grep cactiuser; sleep .2; done
3. Build a host list and do something for all hosts
shell> for x in $(seq -w 1 10); do host=hostname${x}.domain.com; echo "HOST: ${host}"; mysql -uusername -ppassword --host=${host} -e "show variables like '%timeout%'"; done
4. Just a different way to loop through #3
shell> for x in {1..30}; do y=`printf blah%03d $x`; echo $y; done
Well, anyway, I think you might be getting the point! What a great pet to have.
Tags:
-
▶ Reply to This