Skip to content

Instantly share code, notes, and snippets.

@dontstopbelieveing
Last active October 4, 2019 00:17
Show Gist options
  • Save dontstopbelieveing/8815057e8ca2e283c4a23ace863dd74f to your computer and use it in GitHub Desktop.
Save dontstopbelieveing/8815057e8ca2e283c4a23ace863dd74f to your computer and use it in GitHub Desktop.
Collecting metrics
#Slave Lag
#!/usr/bin/bash
log_dir=/logs/
#Slave lag
mysql --login-path=mysqlconn -e "show slave status \G" | grep Seconds| awk '{ print $2 }' | while IFS= read -r line; do printf '%s\t%s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$line"; done | tee -a $log_dir/slave_lag
#Processlist
mysql --login-path=mysqlconn -e "show slave status \G" | grep Seconds| awk '{ print $2 }' | while IFS= read -r line; do printf '%s\t%s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$line"; done | tee -a $log_dir/slave_lag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment