Last active
August 29, 2015 13:59
-
-
Save julesce/10891236 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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