Class: OkComputer::MongoidCheck
- Defined in:
- lib/ok_computer/built_in_checks/mongoid_check.rb
Constant Summary collapse
- ConnectionFailed =
Class.new(StandardError)
Constants inherited from Check
Instance Attribute Summary
Attributes inherited from Check
#failure_occurred, #message, #registrant_name
Instance Method Summary collapse
-
#check ⇒ Object
Public: Return the status of the mongodb.
-
#mongodb_name ⇒ Object
Public: The name of the app’s mongodb.
-
#mongodb_stats ⇒ Object
Public: The stats for the app’s mongodb.
Methods inherited from Check
#clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text
Instance Method Details
#check ⇒ Object
Public: Return the status of the mongodb
4 5 6 7 8 9 |
# File 'lib/ok_computer/built_in_checks/mongoid_check.rb', line 4 def check "Connected to mongodb #{mongodb_name}" rescue ConnectionFailed => e mark_failure "Error: '#{e}'" end |
#mongodb_name ⇒ Object
Public: The name of the app’s mongodb
Returns a string with the mongdb name
27 28 29 |
# File 'lib/ok_computer/built_in_checks/mongoid_check.rb', line 27 def mongodb_name mongodb_stats["db"] end |
#mongodb_stats ⇒ Object
Public: The stats for the app’s mongodb
Returns a hash with the status of the db
14 15 16 17 18 19 20 21 22 |
# File 'lib/ok_computer/built_in_checks/mongoid_check.rb', line 14 def mongodb_stats if Mongoid.respond_to?(:default_session) Mongoid.default_session.command(dbStats: 1) # Mongoid 3+ else Mongoid.database.stats # Mongoid 2 end rescue => e raise ConnectionFailed, e end |