Skip to content

Instantly share code, notes, and snippets.

@julesce
Last active August 29, 2015 13:59
Show Gist options
  • Save julesce/10891236 to your computer and use it in GitHub Desktop.
Save julesce/10891236 to your computer and use it in GitHub Desktop.
EventMachine.run {
EventMachine::PeriodicTimer.new(60){
result = ActiveRecord::Base.connection.select_rows("show global status like 'threads_running'") # => [['threads_running', 1]]
threads_running = result.try(:first).try(:at, 1)
message = "#{threads_running} threads running at #{Time.now}"
puts message
file = File.open("#{Rails.root}/log/mysql_thread_count.log", 'a')
file.puts message
file.close
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment